app.js 606 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316153171531815319153201532115322153231532415325153261532715328153291533015331153321533315334153351533615337153381533915340153411534215343153441534515346153471534815349153501535115352153531535415355153561535715358153591536015361153621536315364153651536615367153681536915370153711537215373153741537515376153771537815379153801538115382153831538415385153861538715388153891539015391153921539315394153951539615397153981539915400154011540215403154041540515406154071540815409154101541115412154131541415415154161541715418154191542015421154221542315424154251542615427154281542915430154311543215433154341543515436154371543815439154401544115442154431544415445154461544715448154491545015451154521545315454154551545615457154581545915460154611546215463154641546515466154671546815469154701547115472154731547415475154761547715478154791548015481154821548315484154851548615487154881548915490154911549215493154941549515496154971549815499155001550115502155031550415505155061550715508155091551015511155121551315514155151551615517155181551915520155211552215523155241552515526155271552815529155301553115532155331553415535155361553715538155391554015541155421554315544155451554615547155481554915550155511555215553155541555515556155571555815559155601556115562155631556415565155661556715568155691557015571155721557315574155751557615577155781557915580155811558215583155841558515586155871558815589155901559115592155931559415595155961559715598155991560015601156021560315604156051560615607156081560915610156111561215613156141561515616156171561815619156201562115622156231562415625156261562715628156291563015631156321563315634156351563615637156381563915640156411564215643156441564515646156471564815649156501565115652156531565415655156561565715658156591566015661156621566315664156651566615667156681566915670156711567215673156741567515676156771567815679156801568115682156831568415685156861568715688156891569015691156921569315694156951569615697156981569915700157011570215703157041570515706157071570815709157101571115712157131571415715157161571715718157191572015721157221572315724157251572615727157281572915730157311573215733157341573515736157371573815739157401574115742157431574415745157461574715748157491575015751157521575315754157551575615757157581575915760157611576215763157641576515766157671576815769157701577115772157731577415775157761577715778157791578015781157821578315784157851578615787157881578915790157911579215793157941579515796157971579815799158001580115802158031580415805158061580715808158091581015811158121581315814158151581615817158181581915820158211582215823158241582515826158271582815829158301583115832158331583415835158361583715838158391584015841158421584315844158451584615847158481584915850158511585215853158541585515856158571585815859158601586115862158631586415865158661586715868158691587015871158721587315874158751587615877158781587915880158811588215883158841588515886158871588815889158901589115892158931589415895158961589715898158991590015901159021590315904159051590615907159081590915910159111591215913159141591515916159171591815919159201592115922159231592415925159261592715928159291593015931159321593315934159351593615937159381593915940159411594215943159441594515946159471594815949159501595115952159531595415955159561595715958159591596015961159621596315964159651596615967159681596915970159711597215973159741597515976159771597815979159801598115982159831598415985159861598715988159891599015991159921599315994159951599615997159981599916000160011600216003160041600516006160071600816009160101601116012160131601416015160161601716018160191602016021160221602316024160251602616027160281602916030160311603216033160341603516036160371603816039160401604116042160431604416045160461604716048160491605016051160521605316054160551605616057160581605916060160611606216063160641606516066160671606816069160701607116072160731607416075160761607716078160791608016081160821608316084160851608616087160881608916090160911609216093160941609516096160971609816099161001610116102161031610416105161061610716108161091611016111161121611316114161151611616117161181611916120161211612216123161241612516126161271612816129161301613116132161331613416135161361613716138161391614016141161421614316144161451614616147161481614916150161511615216153161541615516156161571615816159161601616116162161631616416165161661616716168161691617016171161721617316174161751617616177161781617916180161811618216183161841618516186161871618816189161901619116192161931619416195161961619716198161991620016201162021620316204162051620616207162081620916210162111621216213162141621516216162171621816219162201622116222162231622416225162261622716228162291623016231162321623316234162351623616237162381623916240162411624216243162441624516246162471624816249162501625116252162531625416255162561625716258162591626016261162621626316264162651626616267162681626916270162711627216273162741627516276162771627816279162801628116282162831628416285162861628716288162891629016291162921629316294162951629616297162981629916300163011630216303163041630516306163071630816309163101631116312163131631416315163161631716318163191632016321163221632316324163251632616327163281632916330163311633216333163341633516336163371633816339163401634116342163431634416345163461634716348163491635016351163521635316354163551635616357163581635916360163611636216363163641636516366163671636816369163701637116372163731637416375163761637716378163791638016381163821638316384163851638616387163881638916390163911639216393163941639516396163971639816399164001640116402164031640416405164061640716408164091641016411164121641316414164151641616417164181641916420164211642216423164241642516426164271642816429164301643116432164331643416435164361643716438164391644016441164421644316444164451644616447164481644916450164511645216453164541645516456164571645816459164601646116462164631646416465164661646716468164691647016471164721647316474164751647616477164781647916480164811648216483164841648516486164871648816489164901649116492164931649416495164961649716498164991650016501165021650316504165051650616507165081650916510165111651216513165141651516516165171651816519165201652116522165231652416525165261652716528165291653016531165321653316534165351653616537165381653916540165411654216543165441654516546165471654816549165501655116552165531655416555165561655716558165591656016561165621656316564165651656616567165681656916570165711657216573165741657516576165771657816579165801658116582165831658416585165861658716588165891659016591165921659316594165951659616597165981659916600166011660216603166041660516606166071660816609166101661116612166131661416615166161661716618166191662016621166221662316624166251662616627166281662916630166311663216633166341663516636166371663816639166401664116642166431664416645166461664716648166491665016651166521665316654166551665616657166581665916660166611666216663166641666516666166671666816669166701667116672166731667416675166761667716678166791668016681166821668316684166851668616687166881668916690166911669216693166941669516696166971669816699167001670116702167031670416705167061670716708167091671016711167121671316714167151671616717167181671916720167211672216723167241672516726167271672816729167301673116732167331673416735167361673716738167391674016741167421674316744167451674616747167481674916750167511675216753167541675516756167571675816759167601676116762167631676416765167661676716768167691677016771167721677316774167751677616777167781677916780167811678216783167841678516786167871678816789167901679116792167931679416795167961679716798167991680016801168021680316804168051680616807168081680916810168111681216813168141681516816168171681816819168201682116822168231682416825168261682716828168291683016831168321683316834168351683616837168381683916840168411684216843168441684516846168471684816849168501685116852168531685416855168561685716858168591686016861168621686316864168651686616867168681686916870168711687216873168741687516876168771687816879168801688116882168831688416885168861688716888168891689016891168921689316894168951689616897168981689916900169011690216903169041690516906169071690816909169101691116912169131691416915169161691716918169191692016921169221692316924169251692616927169281692916930169311693216933169341693516936169371693816939169401694116942169431694416945169461694716948169491695016951169521695316954169551695616957169581695916960169611696216963169641696516966169671696816969169701697116972169731697416975169761697716978169791698016981169821698316984169851698616987169881698916990169911699216993169941699516996169971699816999170001700117002170031700417005170061700717008170091701017011170121701317014170151701617017170181701917020170211702217023170241702517026170271702817029170301703117032170331703417035170361703717038170391704017041170421704317044170451704617047170481704917050170511705217053170541705517056170571705817059170601706117062170631706417065170661706717068170691707017071170721707317074170751707617077170781707917080170811708217083170841708517086170871708817089170901709117092170931709417095170961709717098170991710017101171021710317104171051710617107171081710917110171111711217113171141711517116171171711817119171201712117122171231712417125171261712717128171291713017131171321713317134171351713617137171381713917140171411714217143171441714517146171471714817149171501715117152171531715417155171561715717158171591716017161171621716317164171651716617167171681716917170171711717217173171741717517176171771717817179171801718117182171831718417185171861718717188171891719017191171921719317194171951719617197171981719917200172011720217203172041720517206172071720817209172101721117212172131721417215172161721717218172191722017221172221722317224172251722617227172281722917230172311723217233172341723517236172371723817239172401724117242172431724417245172461724717248172491725017251172521725317254172551725617257172581725917260172611726217263172641726517266172671726817269172701727117272172731727417275172761727717278172791728017281172821728317284172851728617287172881728917290172911729217293172941729517296172971729817299173001730117302173031730417305173061730717308173091731017311173121731317314173151731617317173181731917320173211732217323173241732517326173271732817329173301733117332173331733417335173361733717338173391734017341173421734317344173451734617347173481734917350173511735217353173541735517356173571735817359173601736117362173631736417365173661736717368173691737017371173721737317374173751737617377173781737917380173811738217383173841738517386173871738817389173901739117392173931739417395173961739717398173991740017401174021740317404174051740617407174081740917410174111741217413174141741517416174171741817419174201742117422174231742417425174261742717428174291743017431174321743317434174351743617437174381743917440174411744217443174441744517446174471744817449174501745117452174531745417455174561745717458174591746017461174621746317464174651746617467174681746917470174711747217473174741747517476174771747817479174801748117482174831748417485174861748717488174891749017491174921749317494174951749617497174981749917500175011750217503175041750517506175071750817509175101751117512175131751417515175161751717518175191752017521175221752317524175251752617527175281752917530175311753217533175341753517536175371753817539175401754117542175431754417545175461754717548175491755017551175521755317554175551755617557175581755917560175611756217563175641756517566175671756817569175701757117572175731757417575175761757717578175791758017581175821758317584175851758617587175881758917590175911759217593175941759517596175971759817599176001760117602176031760417605176061760717608176091761017611176121761317614176151761617617176181761917620176211762217623176241762517626176271762817629176301763117632176331763417635176361763717638176391764017641176421764317644176451764617647176481764917650176511765217653176541765517656176571765817659176601766117662176631766417665176661766717668176691767017671176721767317674176751767617677176781767917680176811768217683176841768517686176871768817689176901769117692176931769417695176961769717698176991770017701177021770317704177051770617707177081770917710177111771217713177141771517716177171771817719177201772117722177231772417725177261772717728177291773017731177321773317734177351773617737177381773917740177411774217743177441774517746177471774817749177501775117752177531775417755177561775717758177591776017761177621776317764177651776617767177681776917770177711777217773177741777517776177771777817779177801778117782177831778417785177861778717788177891779017791177921779317794177951779617797177981779917800178011780217803178041780517806178071780817809178101781117812178131781417815178161781717818178191782017821178221782317824178251782617827178281782917830178311783217833178341783517836178371783817839178401784117842178431784417845178461784717848178491785017851178521785317854178551785617857178581785917860178611786217863178641786517866178671786817869178701787117872178731787417875178761787717878178791788017881178821788317884178851788617887178881788917890178911789217893178941789517896178971789817899179001790117902179031790417905179061790717908179091791017911179121791317914179151791617917179181791917920179211792217923179241792517926179271792817929179301793117932179331793417935179361793717938179391794017941179421794317944179451794617947179481794917950179511795217953179541795517956179571795817959179601796117962179631796417965179661796717968179691797017971179721797317974179751797617977179781797917980179811798217983179841798517986179871798817989179901799117992179931799417995179961799717998179991800018001180021800318004180051800618007180081800918010180111801218013180141801518016180171801818019180201802118022180231802418025180261802718028180291803018031180321803318034180351803618037180381803918040180411804218043180441804518046180471804818049180501805118052180531805418055180561805718058180591806018061180621806318064180651806618067180681806918070180711807218073180741807518076180771807818079180801808118082180831808418085180861808718088180891809018091180921809318094180951809618097180981809918100181011810218103181041810518106181071810818109181101811118112181131811418115181161811718118181191812018121181221812318124181251812618127181281812918130181311813218133181341813518136181371813818139181401814118142181431814418145181461814718148181491815018151181521815318154181551815618157181581815918160181611816218163181641816518166181671816818169181701817118172181731817418175181761817718178181791818018181181821818318184181851818618187181881818918190181911819218193181941819518196181971819818199182001820118202182031820418205182061820718208182091821018211182121821318214182151821618217182181821918220182211822218223182241822518226182271822818229182301823118232182331823418235182361823718238182391824018241182421824318244182451824618247182481824918250182511825218253182541825518256182571825818259182601826118262182631826418265182661826718268182691827018271182721827318274182751827618277182781827918280182811828218283182841828518286182871828818289182901829118292182931829418295182961829718298182991830018301183021830318304183051830618307183081830918310183111831218313183141831518316183171831818319183201832118322183231832418325183261832718328183291833018331183321833318334183351833618337183381833918340183411834218343183441834518346183471834818349183501835118352183531835418355183561835718358183591836018361183621836318364183651836618367183681836918370183711837218373183741837518376183771837818379183801838118382183831838418385183861838718388183891839018391183921839318394183951839618397183981839918400184011840218403184041840518406184071840818409184101841118412184131841418415184161841718418184191842018421184221842318424184251842618427184281842918430184311843218433184341843518436184371843818439184401844118442184431844418445184461844718448184491845018451184521845318454184551845618457184581845918460184611846218463184641846518466184671846818469184701847118472184731847418475184761847718478184791848018481184821848318484184851848618487184881848918490184911849218493184941849518496184971849818499185001850118502185031850418505185061850718508185091851018511185121851318514185151851618517185181851918520185211852218523185241852518526185271852818529185301853118532185331853418535185361853718538185391854018541185421854318544185451854618547185481854918550185511855218553185541855518556185571855818559185601856118562185631856418565185661856718568185691857018571185721857318574185751857618577185781857918580185811858218583185841858518586185871858818589185901859118592185931859418595185961859718598185991860018601186021860318604186051860618607186081860918610186111861218613186141861518616186171861818619186201862118622186231862418625186261862718628186291863018631186321863318634186351863618637186381863918640186411864218643186441864518646186471864818649186501865118652186531865418655186561865718658186591866018661186621866318664186651866618667186681866918670186711867218673186741867518676186771867818679186801868118682186831868418685186861868718688186891869018691186921869318694186951869618697186981869918700187011870218703187041870518706187071870818709187101871118712187131871418715187161871718718187191872018721187221872318724187251872618727187281872918730187311873218733187341873518736187371873818739187401874118742187431874418745187461874718748187491875018751187521875318754187551875618757187581875918760187611876218763187641876518766187671876818769187701877118772187731877418775187761877718778187791878018781187821878318784187851878618787187881878918790187911879218793187941879518796187971879818799188001880118802188031880418805188061880718808188091881018811188121881318814188151881618817188181881918820188211882218823188241882518826188271882818829188301883118832188331883418835188361883718838188391884018841188421884318844188451884618847188481884918850188511885218853188541885518856188571885818859188601886118862188631886418865188661886718868188691887018871188721887318874188751887618877188781887918880188811888218883188841888518886188871888818889188901889118892188931889418895188961889718898188991890018901189021890318904189051890618907189081890918910189111891218913189141891518916189171891818919189201892118922189231892418925189261892718928189291893018931189321893318934189351893618937189381893918940189411894218943189441894518946189471894818949189501895118952189531895418955189561895718958189591896018961189621896318964189651896618967189681896918970189711897218973189741897518976189771897818979189801898118982189831898418985189861898718988189891899018991189921899318994189951899618997189981899919000190011900219003190041900519006190071900819009190101901119012190131901419015190161901719018190191902019021190221902319024190251902619027190281902919030190311903219033190341903519036190371903819039190401904119042190431904419045190461904719048190491905019051190521905319054190551905619057190581905919060190611906219063190641906519066190671906819069190701907119072190731907419075190761907719078190791908019081190821908319084190851908619087190881908919090190911909219093190941909519096190971909819099191001910119102191031910419105191061910719108191091911019111191121911319114191151911619117191181911919120191211912219123191241912519126191271912819129191301913119132191331913419135191361913719138191391914019141191421914319144191451914619147191481914919150191511915219153191541915519156191571915819159191601916119162191631916419165191661916719168191691917019171191721917319174191751917619177191781917919180191811918219183191841918519186191871918819189191901919119192191931919419195191961919719198191991920019201192021920319204192051920619207192081920919210192111921219213192141921519216192171921819219192201922119222192231922419225192261922719228192291923019231192321923319234192351923619237192381923919240192411924219243192441924519246192471924819249192501925119252192531925419255192561925719258192591926019261192621926319264192651926619267192681926919270192711927219273192741927519276192771927819279192801928119282192831928419285192861928719288192891929019291192921929319294192951929619297192981929919300193011930219303193041930519306193071930819309193101931119312193131931419315193161931719318193191932019321193221932319324193251932619327193281932919330193311933219333193341933519336193371933819339193401934119342193431934419345193461934719348193491935019351193521935319354193551935619357193581935919360193611936219363193641936519366193671936819369193701937119372193731937419375193761937719378193791938019381193821938319384193851938619387193881938919390193911939219393193941939519396193971939819399194001940119402194031940419405194061940719408194091941019411194121941319414194151941619417194181941919420194211942219423194241942519426194271942819429194301943119432194331943419435194361943719438194391944019441194421944319444194451944619447194481944919450194511945219453194541945519456194571945819459194601946119462194631946419465194661946719468194691947019471194721947319474194751947619477194781947919480194811948219483194841948519486194871948819489194901949119492194931949419495194961949719498194991950019501195021950319504195051950619507195081950919510195111951219513195141951519516195171951819519195201952119522195231952419525195261952719528195291953019531195321953319534195351953619537195381953919540195411954219543195441954519546195471954819549195501955119552195531955419555195561955719558195591956019561195621956319564195651956619567195681956919570195711957219573195741957519576195771957819579195801958119582195831958419585195861958719588195891959019591195921959319594195951959619597195981959919600196011960219603196041960519606196071960819609196101961119612196131961419615196161961719618196191962019621196221962319624196251962619627196281962919630196311963219633196341963519636196371963819639196401964119642196431964419645196461964719648196491965019651196521965319654196551965619657196581965919660196611966219663196641966519666196671966819669196701967119672196731967419675196761967719678196791968019681196821968319684196851968619687196881968919690196911969219693196941969519696196971969819699
  1. /******/ (() => { // webpackBootstrap
  2. /******/ var __webpack_modules__ = ({
  3. /***/ "./node_modules/axios/index.js":
  4. /*!*************************************!*\
  5. !*** ./node_modules/axios/index.js ***!
  6. \*************************************/
  7. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  8. module.exports = __webpack_require__(/*! ./lib/axios */ "./node_modules/axios/lib/axios.js");
  9. /***/ }),
  10. /***/ "./node_modules/axios/lib/adapters/xhr.js":
  11. /*!************************************************!*\
  12. !*** ./node_modules/axios/lib/adapters/xhr.js ***!
  13. \************************************************/
  14. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  15. "use strict";
  16. var utils = __webpack_require__(/*! ./../utils */ "./node_modules/axios/lib/utils.js");
  17. var settle = __webpack_require__(/*! ./../core/settle */ "./node_modules/axios/lib/core/settle.js");
  18. var cookies = __webpack_require__(/*! ./../helpers/cookies */ "./node_modules/axios/lib/helpers/cookies.js");
  19. var buildURL = __webpack_require__(/*! ./../helpers/buildURL */ "./node_modules/axios/lib/helpers/buildURL.js");
  20. var buildFullPath = __webpack_require__(/*! ../core/buildFullPath */ "./node_modules/axios/lib/core/buildFullPath.js");
  21. var parseHeaders = __webpack_require__(/*! ./../helpers/parseHeaders */ "./node_modules/axios/lib/helpers/parseHeaders.js");
  22. var isURLSameOrigin = __webpack_require__(/*! ./../helpers/isURLSameOrigin */ "./node_modules/axios/lib/helpers/isURLSameOrigin.js");
  23. var createError = __webpack_require__(/*! ../core/createError */ "./node_modules/axios/lib/core/createError.js");
  24. module.exports = function xhrAdapter(config) {
  25. return new Promise(function dispatchXhrRequest(resolve, reject) {
  26. var requestData = config.data;
  27. var requestHeaders = config.headers;
  28. var responseType = config.responseType;
  29. if (utils.isFormData(requestData)) {
  30. delete requestHeaders['Content-Type']; // Let the browser set it
  31. }
  32. var request = new XMLHttpRequest();
  33. // HTTP basic authentication
  34. if (config.auth) {
  35. var username = config.auth.username || '';
  36. var password = config.auth.password ? unescape(encodeURIComponent(config.auth.password)) : '';
  37. requestHeaders.Authorization = 'Basic ' + btoa(username + ':' + password);
  38. }
  39. var fullPath = buildFullPath(config.baseURL, config.url);
  40. request.open(config.method.toUpperCase(), buildURL(fullPath, config.params, config.paramsSerializer), true);
  41. // Set the request timeout in MS
  42. request.timeout = config.timeout;
  43. function onloadend() {
  44. if (!request) {
  45. return;
  46. }
  47. // Prepare the response
  48. var responseHeaders = 'getAllResponseHeaders' in request ? parseHeaders(request.getAllResponseHeaders()) : null;
  49. var responseData = !responseType || responseType === 'text' || responseType === 'json' ?
  50. request.responseText : request.response;
  51. var response = {
  52. data: responseData,
  53. status: request.status,
  54. statusText: request.statusText,
  55. headers: responseHeaders,
  56. config: config,
  57. request: request
  58. };
  59. settle(resolve, reject, response);
  60. // Clean up request
  61. request = null;
  62. }
  63. if ('onloadend' in request) {
  64. // Use onloadend if available
  65. request.onloadend = onloadend;
  66. } else {
  67. // Listen for ready state to emulate onloadend
  68. request.onreadystatechange = function handleLoad() {
  69. if (!request || request.readyState !== 4) {
  70. return;
  71. }
  72. // The request errored out and we didn't get a response, this will be
  73. // handled by onerror instead
  74. // With one exception: request that using file: protocol, most browsers
  75. // will return status as 0 even though it's a successful request
  76. if (request.status === 0 && !(request.responseURL && request.responseURL.indexOf('file:') === 0)) {
  77. return;
  78. }
  79. // readystate handler is calling before onerror or ontimeout handlers,
  80. // so we should call onloadend on the next 'tick'
  81. setTimeout(onloadend);
  82. };
  83. }
  84. // Handle browser request cancellation (as opposed to a manual cancellation)
  85. request.onabort = function handleAbort() {
  86. if (!request) {
  87. return;
  88. }
  89. reject(createError('Request aborted', config, 'ECONNABORTED', request));
  90. // Clean up request
  91. request = null;
  92. };
  93. // Handle low level network errors
  94. request.onerror = function handleError() {
  95. // Real errors are hidden from us by the browser
  96. // onerror should only fire if it's a network error
  97. reject(createError('Network Error', config, null, request));
  98. // Clean up request
  99. request = null;
  100. };
  101. // Handle timeout
  102. request.ontimeout = function handleTimeout() {
  103. var timeoutErrorMessage = 'timeout of ' + config.timeout + 'ms exceeded';
  104. if (config.timeoutErrorMessage) {
  105. timeoutErrorMessage = config.timeoutErrorMessage;
  106. }
  107. reject(createError(
  108. timeoutErrorMessage,
  109. config,
  110. config.transitional && config.transitional.clarifyTimeoutError ? 'ETIMEDOUT' : 'ECONNABORTED',
  111. request));
  112. // Clean up request
  113. request = null;
  114. };
  115. // Add xsrf header
  116. // This is only done if running in a standard browser environment.
  117. // Specifically not if we're in a web worker, or react-native.
  118. if (utils.isStandardBrowserEnv()) {
  119. // Add xsrf header
  120. var xsrfValue = (config.withCredentials || isURLSameOrigin(fullPath)) && config.xsrfCookieName ?
  121. cookies.read(config.xsrfCookieName) :
  122. undefined;
  123. if (xsrfValue) {
  124. requestHeaders[config.xsrfHeaderName] = xsrfValue;
  125. }
  126. }
  127. // Add headers to the request
  128. if ('setRequestHeader' in request) {
  129. utils.forEach(requestHeaders, function setRequestHeader(val, key) {
  130. if (typeof requestData === 'undefined' && key.toLowerCase() === 'content-type') {
  131. // Remove Content-Type if data is undefined
  132. delete requestHeaders[key];
  133. } else {
  134. // Otherwise add header to the request
  135. request.setRequestHeader(key, val);
  136. }
  137. });
  138. }
  139. // Add withCredentials to request if needed
  140. if (!utils.isUndefined(config.withCredentials)) {
  141. request.withCredentials = !!config.withCredentials;
  142. }
  143. // Add responseType to request if needed
  144. if (responseType && responseType !== 'json') {
  145. request.responseType = config.responseType;
  146. }
  147. // Handle progress if needed
  148. if (typeof config.onDownloadProgress === 'function') {
  149. request.addEventListener('progress', config.onDownloadProgress);
  150. }
  151. // Not all browsers support upload events
  152. if (typeof config.onUploadProgress === 'function' && request.upload) {
  153. request.upload.addEventListener('progress', config.onUploadProgress);
  154. }
  155. if (config.cancelToken) {
  156. // Handle cancellation
  157. config.cancelToken.promise.then(function onCanceled(cancel) {
  158. if (!request) {
  159. return;
  160. }
  161. request.abort();
  162. reject(cancel);
  163. // Clean up request
  164. request = null;
  165. });
  166. }
  167. if (!requestData) {
  168. requestData = null;
  169. }
  170. // Send the request
  171. request.send(requestData);
  172. });
  173. };
  174. /***/ }),
  175. /***/ "./node_modules/axios/lib/axios.js":
  176. /*!*****************************************!*\
  177. !*** ./node_modules/axios/lib/axios.js ***!
  178. \*****************************************/
  179. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  180. "use strict";
  181. var utils = __webpack_require__(/*! ./utils */ "./node_modules/axios/lib/utils.js");
  182. var bind = __webpack_require__(/*! ./helpers/bind */ "./node_modules/axios/lib/helpers/bind.js");
  183. var Axios = __webpack_require__(/*! ./core/Axios */ "./node_modules/axios/lib/core/Axios.js");
  184. var mergeConfig = __webpack_require__(/*! ./core/mergeConfig */ "./node_modules/axios/lib/core/mergeConfig.js");
  185. var defaults = __webpack_require__(/*! ./defaults */ "./node_modules/axios/lib/defaults.js");
  186. /**
  187. * Create an instance of Axios
  188. *
  189. * @param {Object} defaultConfig The default config for the instance
  190. * @return {Axios} A new instance of Axios
  191. */
  192. function createInstance(defaultConfig) {
  193. var context = new Axios(defaultConfig);
  194. var instance = bind(Axios.prototype.request, context);
  195. // Copy axios.prototype to instance
  196. utils.extend(instance, Axios.prototype, context);
  197. // Copy context to instance
  198. utils.extend(instance, context);
  199. return instance;
  200. }
  201. // Create the default instance to be exported
  202. var axios = createInstance(defaults);
  203. // Expose Axios class to allow class inheritance
  204. axios.Axios = Axios;
  205. // Factory for creating new instances
  206. axios.create = function create(instanceConfig) {
  207. return createInstance(mergeConfig(axios.defaults, instanceConfig));
  208. };
  209. // Expose Cancel & CancelToken
  210. axios.Cancel = __webpack_require__(/*! ./cancel/Cancel */ "./node_modules/axios/lib/cancel/Cancel.js");
  211. axios.CancelToken = __webpack_require__(/*! ./cancel/CancelToken */ "./node_modules/axios/lib/cancel/CancelToken.js");
  212. axios.isCancel = __webpack_require__(/*! ./cancel/isCancel */ "./node_modules/axios/lib/cancel/isCancel.js");
  213. // Expose all/spread
  214. axios.all = function all(promises) {
  215. return Promise.all(promises);
  216. };
  217. axios.spread = __webpack_require__(/*! ./helpers/spread */ "./node_modules/axios/lib/helpers/spread.js");
  218. // Expose isAxiosError
  219. axios.isAxiosError = __webpack_require__(/*! ./helpers/isAxiosError */ "./node_modules/axios/lib/helpers/isAxiosError.js");
  220. module.exports = axios;
  221. // Allow use of default import syntax in TypeScript
  222. module.exports["default"] = axios;
  223. /***/ }),
  224. /***/ "./node_modules/axios/lib/cancel/Cancel.js":
  225. /*!*************************************************!*\
  226. !*** ./node_modules/axios/lib/cancel/Cancel.js ***!
  227. \*************************************************/
  228. /***/ ((module) => {
  229. "use strict";
  230. /**
  231. * A `Cancel` is an object that is thrown when an operation is canceled.
  232. *
  233. * @class
  234. * @param {string=} message The message.
  235. */
  236. function Cancel(message) {
  237. this.message = message;
  238. }
  239. Cancel.prototype.toString = function toString() {
  240. return 'Cancel' + (this.message ? ': ' + this.message : '');
  241. };
  242. Cancel.prototype.__CANCEL__ = true;
  243. module.exports = Cancel;
  244. /***/ }),
  245. /***/ "./node_modules/axios/lib/cancel/CancelToken.js":
  246. /*!******************************************************!*\
  247. !*** ./node_modules/axios/lib/cancel/CancelToken.js ***!
  248. \******************************************************/
  249. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  250. "use strict";
  251. var Cancel = __webpack_require__(/*! ./Cancel */ "./node_modules/axios/lib/cancel/Cancel.js");
  252. /**
  253. * A `CancelToken` is an object that can be used to request cancellation of an operation.
  254. *
  255. * @class
  256. * @param {Function} executor The executor function.
  257. */
  258. function CancelToken(executor) {
  259. if (typeof executor !== 'function') {
  260. throw new TypeError('executor must be a function.');
  261. }
  262. var resolvePromise;
  263. this.promise = new Promise(function promiseExecutor(resolve) {
  264. resolvePromise = resolve;
  265. });
  266. var token = this;
  267. executor(function cancel(message) {
  268. if (token.reason) {
  269. // Cancellation has already been requested
  270. return;
  271. }
  272. token.reason = new Cancel(message);
  273. resolvePromise(token.reason);
  274. });
  275. }
  276. /**
  277. * Throws a `Cancel` if cancellation has been requested.
  278. */
  279. CancelToken.prototype.throwIfRequested = function throwIfRequested() {
  280. if (this.reason) {
  281. throw this.reason;
  282. }
  283. };
  284. /**
  285. * Returns an object that contains a new `CancelToken` and a function that, when called,
  286. * cancels the `CancelToken`.
  287. */
  288. CancelToken.source = function source() {
  289. var cancel;
  290. var token = new CancelToken(function executor(c) {
  291. cancel = c;
  292. });
  293. return {
  294. token: token,
  295. cancel: cancel
  296. };
  297. };
  298. module.exports = CancelToken;
  299. /***/ }),
  300. /***/ "./node_modules/axios/lib/cancel/isCancel.js":
  301. /*!***************************************************!*\
  302. !*** ./node_modules/axios/lib/cancel/isCancel.js ***!
  303. \***************************************************/
  304. /***/ ((module) => {
  305. "use strict";
  306. module.exports = function isCancel(value) {
  307. return !!(value && value.__CANCEL__);
  308. };
  309. /***/ }),
  310. /***/ "./node_modules/axios/lib/core/Axios.js":
  311. /*!**********************************************!*\
  312. !*** ./node_modules/axios/lib/core/Axios.js ***!
  313. \**********************************************/
  314. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  315. "use strict";
  316. var utils = __webpack_require__(/*! ./../utils */ "./node_modules/axios/lib/utils.js");
  317. var buildURL = __webpack_require__(/*! ../helpers/buildURL */ "./node_modules/axios/lib/helpers/buildURL.js");
  318. var InterceptorManager = __webpack_require__(/*! ./InterceptorManager */ "./node_modules/axios/lib/core/InterceptorManager.js");
  319. var dispatchRequest = __webpack_require__(/*! ./dispatchRequest */ "./node_modules/axios/lib/core/dispatchRequest.js");
  320. var mergeConfig = __webpack_require__(/*! ./mergeConfig */ "./node_modules/axios/lib/core/mergeConfig.js");
  321. var validator = __webpack_require__(/*! ../helpers/validator */ "./node_modules/axios/lib/helpers/validator.js");
  322. var validators = validator.validators;
  323. /**
  324. * Create a new instance of Axios
  325. *
  326. * @param {Object} instanceConfig The default config for the instance
  327. */
  328. function Axios(instanceConfig) {
  329. this.defaults = instanceConfig;
  330. this.interceptors = {
  331. request: new InterceptorManager(),
  332. response: new InterceptorManager()
  333. };
  334. }
  335. /**
  336. * Dispatch a request
  337. *
  338. * @param {Object} config The config specific for this request (merged with this.defaults)
  339. */
  340. Axios.prototype.request = function request(config) {
  341. /*eslint no-param-reassign:0*/
  342. // Allow for axios('example/url'[, config]) a la fetch API
  343. if (typeof config === 'string') {
  344. config = arguments[1] || {};
  345. config.url = arguments[0];
  346. } else {
  347. config = config || {};
  348. }
  349. config = mergeConfig(this.defaults, config);
  350. // Set config.method
  351. if (config.method) {
  352. config.method = config.method.toLowerCase();
  353. } else if (this.defaults.method) {
  354. config.method = this.defaults.method.toLowerCase();
  355. } else {
  356. config.method = 'get';
  357. }
  358. var transitional = config.transitional;
  359. if (transitional !== undefined) {
  360. validator.assertOptions(transitional, {
  361. silentJSONParsing: validators.transitional(validators.boolean, '1.0.0'),
  362. forcedJSONParsing: validators.transitional(validators.boolean, '1.0.0'),
  363. clarifyTimeoutError: validators.transitional(validators.boolean, '1.0.0')
  364. }, false);
  365. }
  366. // filter out skipped interceptors
  367. var requestInterceptorChain = [];
  368. var synchronousRequestInterceptors = true;
  369. this.interceptors.request.forEach(function unshiftRequestInterceptors(interceptor) {
  370. if (typeof interceptor.runWhen === 'function' && interceptor.runWhen(config) === false) {
  371. return;
  372. }
  373. synchronousRequestInterceptors = synchronousRequestInterceptors && interceptor.synchronous;
  374. requestInterceptorChain.unshift(interceptor.fulfilled, interceptor.rejected);
  375. });
  376. var responseInterceptorChain = [];
  377. this.interceptors.response.forEach(function pushResponseInterceptors(interceptor) {
  378. responseInterceptorChain.push(interceptor.fulfilled, interceptor.rejected);
  379. });
  380. var promise;
  381. if (!synchronousRequestInterceptors) {
  382. var chain = [dispatchRequest, undefined];
  383. Array.prototype.unshift.apply(chain, requestInterceptorChain);
  384. chain = chain.concat(responseInterceptorChain);
  385. promise = Promise.resolve(config);
  386. while (chain.length) {
  387. promise = promise.then(chain.shift(), chain.shift());
  388. }
  389. return promise;
  390. }
  391. var newConfig = config;
  392. while (requestInterceptorChain.length) {
  393. var onFulfilled = requestInterceptorChain.shift();
  394. var onRejected = requestInterceptorChain.shift();
  395. try {
  396. newConfig = onFulfilled(newConfig);
  397. } catch (error) {
  398. onRejected(error);
  399. break;
  400. }
  401. }
  402. try {
  403. promise = dispatchRequest(newConfig);
  404. } catch (error) {
  405. return Promise.reject(error);
  406. }
  407. while (responseInterceptorChain.length) {
  408. promise = promise.then(responseInterceptorChain.shift(), responseInterceptorChain.shift());
  409. }
  410. return promise;
  411. };
  412. Axios.prototype.getUri = function getUri(config) {
  413. config = mergeConfig(this.defaults, config);
  414. return buildURL(config.url, config.params, config.paramsSerializer).replace(/^\?/, '');
  415. };
  416. // Provide aliases for supported request methods
  417. utils.forEach(['delete', 'get', 'head', 'options'], function forEachMethodNoData(method) {
  418. /*eslint func-names:0*/
  419. Axios.prototype[method] = function(url, config) {
  420. return this.request(mergeConfig(config || {}, {
  421. method: method,
  422. url: url,
  423. data: (config || {}).data
  424. }));
  425. };
  426. });
  427. utils.forEach(['post', 'put', 'patch'], function forEachMethodWithData(method) {
  428. /*eslint func-names:0*/
  429. Axios.prototype[method] = function(url, data, config) {
  430. return this.request(mergeConfig(config || {}, {
  431. method: method,
  432. url: url,
  433. data: data
  434. }));
  435. };
  436. });
  437. module.exports = Axios;
  438. /***/ }),
  439. /***/ "./node_modules/axios/lib/core/InterceptorManager.js":
  440. /*!***********************************************************!*\
  441. !*** ./node_modules/axios/lib/core/InterceptorManager.js ***!
  442. \***********************************************************/
  443. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  444. "use strict";
  445. var utils = __webpack_require__(/*! ./../utils */ "./node_modules/axios/lib/utils.js");
  446. function InterceptorManager() {
  447. this.handlers = [];
  448. }
  449. /**
  450. * Add a new interceptor to the stack
  451. *
  452. * @param {Function} fulfilled The function to handle `then` for a `Promise`
  453. * @param {Function} rejected The function to handle `reject` for a `Promise`
  454. *
  455. * @return {Number} An ID used to remove interceptor later
  456. */
  457. InterceptorManager.prototype.use = function use(fulfilled, rejected, options) {
  458. this.handlers.push({
  459. fulfilled: fulfilled,
  460. rejected: rejected,
  461. synchronous: options ? options.synchronous : false,
  462. runWhen: options ? options.runWhen : null
  463. });
  464. return this.handlers.length - 1;
  465. };
  466. /**
  467. * Remove an interceptor from the stack
  468. *
  469. * @param {Number} id The ID that was returned by `use`
  470. */
  471. InterceptorManager.prototype.eject = function eject(id) {
  472. if (this.handlers[id]) {
  473. this.handlers[id] = null;
  474. }
  475. };
  476. /**
  477. * Iterate over all the registered interceptors
  478. *
  479. * This method is particularly useful for skipping over any
  480. * interceptors that may have become `null` calling `eject`.
  481. *
  482. * @param {Function} fn The function to call for each interceptor
  483. */
  484. InterceptorManager.prototype.forEach = function forEach(fn) {
  485. utils.forEach(this.handlers, function forEachHandler(h) {
  486. if (h !== null) {
  487. fn(h);
  488. }
  489. });
  490. };
  491. module.exports = InterceptorManager;
  492. /***/ }),
  493. /***/ "./node_modules/axios/lib/core/buildFullPath.js":
  494. /*!******************************************************!*\
  495. !*** ./node_modules/axios/lib/core/buildFullPath.js ***!
  496. \******************************************************/
  497. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  498. "use strict";
  499. var isAbsoluteURL = __webpack_require__(/*! ../helpers/isAbsoluteURL */ "./node_modules/axios/lib/helpers/isAbsoluteURL.js");
  500. var combineURLs = __webpack_require__(/*! ../helpers/combineURLs */ "./node_modules/axios/lib/helpers/combineURLs.js");
  501. /**
  502. * Creates a new URL by combining the baseURL with the requestedURL,
  503. * only when the requestedURL is not already an absolute URL.
  504. * If the requestURL is absolute, this function returns the requestedURL untouched.
  505. *
  506. * @param {string} baseURL The base URL
  507. * @param {string} requestedURL Absolute or relative URL to combine
  508. * @returns {string} The combined full path
  509. */
  510. module.exports = function buildFullPath(baseURL, requestedURL) {
  511. if (baseURL && !isAbsoluteURL(requestedURL)) {
  512. return combineURLs(baseURL, requestedURL);
  513. }
  514. return requestedURL;
  515. };
  516. /***/ }),
  517. /***/ "./node_modules/axios/lib/core/createError.js":
  518. /*!****************************************************!*\
  519. !*** ./node_modules/axios/lib/core/createError.js ***!
  520. \****************************************************/
  521. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  522. "use strict";
  523. var enhanceError = __webpack_require__(/*! ./enhanceError */ "./node_modules/axios/lib/core/enhanceError.js");
  524. /**
  525. * Create an Error with the specified message, config, error code, request and response.
  526. *
  527. * @param {string} message The error message.
  528. * @param {Object} config The config.
  529. * @param {string} [code] The error code (for example, 'ECONNABORTED').
  530. * @param {Object} [request] The request.
  531. * @param {Object} [response] The response.
  532. * @returns {Error} The created error.
  533. */
  534. module.exports = function createError(message, config, code, request, response) {
  535. var error = new Error(message);
  536. return enhanceError(error, config, code, request, response);
  537. };
  538. /***/ }),
  539. /***/ "./node_modules/axios/lib/core/dispatchRequest.js":
  540. /*!********************************************************!*\
  541. !*** ./node_modules/axios/lib/core/dispatchRequest.js ***!
  542. \********************************************************/
  543. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  544. "use strict";
  545. var utils = __webpack_require__(/*! ./../utils */ "./node_modules/axios/lib/utils.js");
  546. var transformData = __webpack_require__(/*! ./transformData */ "./node_modules/axios/lib/core/transformData.js");
  547. var isCancel = __webpack_require__(/*! ../cancel/isCancel */ "./node_modules/axios/lib/cancel/isCancel.js");
  548. var defaults = __webpack_require__(/*! ../defaults */ "./node_modules/axios/lib/defaults.js");
  549. /**
  550. * Throws a `Cancel` if cancellation has been requested.
  551. */
  552. function throwIfCancellationRequested(config) {
  553. if (config.cancelToken) {
  554. config.cancelToken.throwIfRequested();
  555. }
  556. }
  557. /**
  558. * Dispatch a request to the server using the configured adapter.
  559. *
  560. * @param {object} config The config that is to be used for the request
  561. * @returns {Promise} The Promise to be fulfilled
  562. */
  563. module.exports = function dispatchRequest(config) {
  564. throwIfCancellationRequested(config);
  565. // Ensure headers exist
  566. config.headers = config.headers || {};
  567. // Transform request data
  568. config.data = transformData.call(
  569. config,
  570. config.data,
  571. config.headers,
  572. config.transformRequest
  573. );
  574. // Flatten headers
  575. config.headers = utils.merge(
  576. config.headers.common || {},
  577. config.headers[config.method] || {},
  578. config.headers
  579. );
  580. utils.forEach(
  581. ['delete', 'get', 'head', 'post', 'put', 'patch', 'common'],
  582. function cleanHeaderConfig(method) {
  583. delete config.headers[method];
  584. }
  585. );
  586. var adapter = config.adapter || defaults.adapter;
  587. return adapter(config).then(function onAdapterResolution(response) {
  588. throwIfCancellationRequested(config);
  589. // Transform response data
  590. response.data = transformData.call(
  591. config,
  592. response.data,
  593. response.headers,
  594. config.transformResponse
  595. );
  596. return response;
  597. }, function onAdapterRejection(reason) {
  598. if (!isCancel(reason)) {
  599. throwIfCancellationRequested(config);
  600. // Transform response data
  601. if (reason && reason.response) {
  602. reason.response.data = transformData.call(
  603. config,
  604. reason.response.data,
  605. reason.response.headers,
  606. config.transformResponse
  607. );
  608. }
  609. }
  610. return Promise.reject(reason);
  611. });
  612. };
  613. /***/ }),
  614. /***/ "./node_modules/axios/lib/core/enhanceError.js":
  615. /*!*****************************************************!*\
  616. !*** ./node_modules/axios/lib/core/enhanceError.js ***!
  617. \*****************************************************/
  618. /***/ ((module) => {
  619. "use strict";
  620. /**
  621. * Update an Error with the specified config, error code, and response.
  622. *
  623. * @param {Error} error The error to update.
  624. * @param {Object} config The config.
  625. * @param {string} [code] The error code (for example, 'ECONNABORTED').
  626. * @param {Object} [request] The request.
  627. * @param {Object} [response] The response.
  628. * @returns {Error} The error.
  629. */
  630. module.exports = function enhanceError(error, config, code, request, response) {
  631. error.config = config;
  632. if (code) {
  633. error.code = code;
  634. }
  635. error.request = request;
  636. error.response = response;
  637. error.isAxiosError = true;
  638. error.toJSON = function toJSON() {
  639. return {
  640. // Standard
  641. message: this.message,
  642. name: this.name,
  643. // Microsoft
  644. description: this.description,
  645. number: this.number,
  646. // Mozilla
  647. fileName: this.fileName,
  648. lineNumber: this.lineNumber,
  649. columnNumber: this.columnNumber,
  650. stack: this.stack,
  651. // Axios
  652. config: this.config,
  653. code: this.code
  654. };
  655. };
  656. return error;
  657. };
  658. /***/ }),
  659. /***/ "./node_modules/axios/lib/core/mergeConfig.js":
  660. /*!****************************************************!*\
  661. !*** ./node_modules/axios/lib/core/mergeConfig.js ***!
  662. \****************************************************/
  663. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  664. "use strict";
  665. var utils = __webpack_require__(/*! ../utils */ "./node_modules/axios/lib/utils.js");
  666. /**
  667. * Config-specific merge-function which creates a new config-object
  668. * by merging two configuration objects together.
  669. *
  670. * @param {Object} config1
  671. * @param {Object} config2
  672. * @returns {Object} New object resulting from merging config2 to config1
  673. */
  674. module.exports = function mergeConfig(config1, config2) {
  675. // eslint-disable-next-line no-param-reassign
  676. config2 = config2 || {};
  677. var config = {};
  678. var valueFromConfig2Keys = ['url', 'method', 'data'];
  679. var mergeDeepPropertiesKeys = ['headers', 'auth', 'proxy', 'params'];
  680. var defaultToConfig2Keys = [
  681. 'baseURL', 'transformRequest', 'transformResponse', 'paramsSerializer',
  682. 'timeout', 'timeoutMessage', 'withCredentials', 'adapter', 'responseType', 'xsrfCookieName',
  683. 'xsrfHeaderName', 'onUploadProgress', 'onDownloadProgress', 'decompress',
  684. 'maxContentLength', 'maxBodyLength', 'maxRedirects', 'transport', 'httpAgent',
  685. 'httpsAgent', 'cancelToken', 'socketPath', 'responseEncoding'
  686. ];
  687. var directMergeKeys = ['validateStatus'];
  688. function getMergedValue(target, source) {
  689. if (utils.isPlainObject(target) && utils.isPlainObject(source)) {
  690. return utils.merge(target, source);
  691. } else if (utils.isPlainObject(source)) {
  692. return utils.merge({}, source);
  693. } else if (utils.isArray(source)) {
  694. return source.slice();
  695. }
  696. return source;
  697. }
  698. function mergeDeepProperties(prop) {
  699. if (!utils.isUndefined(config2[prop])) {
  700. config[prop] = getMergedValue(config1[prop], config2[prop]);
  701. } else if (!utils.isUndefined(config1[prop])) {
  702. config[prop] = getMergedValue(undefined, config1[prop]);
  703. }
  704. }
  705. utils.forEach(valueFromConfig2Keys, function valueFromConfig2(prop) {
  706. if (!utils.isUndefined(config2[prop])) {
  707. config[prop] = getMergedValue(undefined, config2[prop]);
  708. }
  709. });
  710. utils.forEach(mergeDeepPropertiesKeys, mergeDeepProperties);
  711. utils.forEach(defaultToConfig2Keys, function defaultToConfig2(prop) {
  712. if (!utils.isUndefined(config2[prop])) {
  713. config[prop] = getMergedValue(undefined, config2[prop]);
  714. } else if (!utils.isUndefined(config1[prop])) {
  715. config[prop] = getMergedValue(undefined, config1[prop]);
  716. }
  717. });
  718. utils.forEach(directMergeKeys, function merge(prop) {
  719. if (prop in config2) {
  720. config[prop] = getMergedValue(config1[prop], config2[prop]);
  721. } else if (prop in config1) {
  722. config[prop] = getMergedValue(undefined, config1[prop]);
  723. }
  724. });
  725. var axiosKeys = valueFromConfig2Keys
  726. .concat(mergeDeepPropertiesKeys)
  727. .concat(defaultToConfig2Keys)
  728. .concat(directMergeKeys);
  729. var otherKeys = Object
  730. .keys(config1)
  731. .concat(Object.keys(config2))
  732. .filter(function filterAxiosKeys(key) {
  733. return axiosKeys.indexOf(key) === -1;
  734. });
  735. utils.forEach(otherKeys, mergeDeepProperties);
  736. return config;
  737. };
  738. /***/ }),
  739. /***/ "./node_modules/axios/lib/core/settle.js":
  740. /*!***********************************************!*\
  741. !*** ./node_modules/axios/lib/core/settle.js ***!
  742. \***********************************************/
  743. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  744. "use strict";
  745. var createError = __webpack_require__(/*! ./createError */ "./node_modules/axios/lib/core/createError.js");
  746. /**
  747. * Resolve or reject a Promise based on response status.
  748. *
  749. * @param {Function} resolve A function that resolves the promise.
  750. * @param {Function} reject A function that rejects the promise.
  751. * @param {object} response The response.
  752. */
  753. module.exports = function settle(resolve, reject, response) {
  754. var validateStatus = response.config.validateStatus;
  755. if (!response.status || !validateStatus || validateStatus(response.status)) {
  756. resolve(response);
  757. } else {
  758. reject(createError(
  759. 'Request failed with status code ' + response.status,
  760. response.config,
  761. null,
  762. response.request,
  763. response
  764. ));
  765. }
  766. };
  767. /***/ }),
  768. /***/ "./node_modules/axios/lib/core/transformData.js":
  769. /*!******************************************************!*\
  770. !*** ./node_modules/axios/lib/core/transformData.js ***!
  771. \******************************************************/
  772. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  773. "use strict";
  774. var utils = __webpack_require__(/*! ./../utils */ "./node_modules/axios/lib/utils.js");
  775. var defaults = __webpack_require__(/*! ./../defaults */ "./node_modules/axios/lib/defaults.js");
  776. /**
  777. * Transform the data for a request or a response
  778. *
  779. * @param {Object|String} data The data to be transformed
  780. * @param {Array} headers The headers for the request or response
  781. * @param {Array|Function} fns A single function or Array of functions
  782. * @returns {*} The resulting transformed data
  783. */
  784. module.exports = function transformData(data, headers, fns) {
  785. var context = this || defaults;
  786. /*eslint no-param-reassign:0*/
  787. utils.forEach(fns, function transform(fn) {
  788. data = fn.call(context, data, headers);
  789. });
  790. return data;
  791. };
  792. /***/ }),
  793. /***/ "./node_modules/axios/lib/defaults.js":
  794. /*!********************************************!*\
  795. !*** ./node_modules/axios/lib/defaults.js ***!
  796. \********************************************/
  797. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  798. "use strict";
  799. /* provided dependency */ var process = __webpack_require__(/*! process/browser.js */ "./node_modules/process/browser.js");
  800. var utils = __webpack_require__(/*! ./utils */ "./node_modules/axios/lib/utils.js");
  801. var normalizeHeaderName = __webpack_require__(/*! ./helpers/normalizeHeaderName */ "./node_modules/axios/lib/helpers/normalizeHeaderName.js");
  802. var enhanceError = __webpack_require__(/*! ./core/enhanceError */ "./node_modules/axios/lib/core/enhanceError.js");
  803. var DEFAULT_CONTENT_TYPE = {
  804. 'Content-Type': 'application/x-www-form-urlencoded'
  805. };
  806. function setContentTypeIfUnset(headers, value) {
  807. if (!utils.isUndefined(headers) && utils.isUndefined(headers['Content-Type'])) {
  808. headers['Content-Type'] = value;
  809. }
  810. }
  811. function getDefaultAdapter() {
  812. var adapter;
  813. if (typeof XMLHttpRequest !== 'undefined') {
  814. // For browsers use XHR adapter
  815. adapter = __webpack_require__(/*! ./adapters/xhr */ "./node_modules/axios/lib/adapters/xhr.js");
  816. } else if (typeof process !== 'undefined' && Object.prototype.toString.call(process) === '[object process]') {
  817. // For node use HTTP adapter
  818. adapter = __webpack_require__(/*! ./adapters/http */ "./node_modules/axios/lib/adapters/xhr.js");
  819. }
  820. return adapter;
  821. }
  822. function stringifySafely(rawValue, parser, encoder) {
  823. if (utils.isString(rawValue)) {
  824. try {
  825. (parser || JSON.parse)(rawValue);
  826. return utils.trim(rawValue);
  827. } catch (e) {
  828. if (e.name !== 'SyntaxError') {
  829. throw e;
  830. }
  831. }
  832. }
  833. return (encoder || JSON.stringify)(rawValue);
  834. }
  835. var defaults = {
  836. transitional: {
  837. silentJSONParsing: true,
  838. forcedJSONParsing: true,
  839. clarifyTimeoutError: false
  840. },
  841. adapter: getDefaultAdapter(),
  842. transformRequest: [function transformRequest(data, headers) {
  843. normalizeHeaderName(headers, 'Accept');
  844. normalizeHeaderName(headers, 'Content-Type');
  845. if (utils.isFormData(data) ||
  846. utils.isArrayBuffer(data) ||
  847. utils.isBuffer(data) ||
  848. utils.isStream(data) ||
  849. utils.isFile(data) ||
  850. utils.isBlob(data)
  851. ) {
  852. return data;
  853. }
  854. if (utils.isArrayBufferView(data)) {
  855. return data.buffer;
  856. }
  857. if (utils.isURLSearchParams(data)) {
  858. setContentTypeIfUnset(headers, 'application/x-www-form-urlencoded;charset=utf-8');
  859. return data.toString();
  860. }
  861. if (utils.isObject(data) || (headers && headers['Content-Type'] === 'application/json')) {
  862. setContentTypeIfUnset(headers, 'application/json');
  863. return stringifySafely(data);
  864. }
  865. return data;
  866. }],
  867. transformResponse: [function transformResponse(data) {
  868. var transitional = this.transitional;
  869. var silentJSONParsing = transitional && transitional.silentJSONParsing;
  870. var forcedJSONParsing = transitional && transitional.forcedJSONParsing;
  871. var strictJSONParsing = !silentJSONParsing && this.responseType === 'json';
  872. if (strictJSONParsing || (forcedJSONParsing && utils.isString(data) && data.length)) {
  873. try {
  874. return JSON.parse(data);
  875. } catch (e) {
  876. if (strictJSONParsing) {
  877. if (e.name === 'SyntaxError') {
  878. throw enhanceError(e, this, 'E_JSON_PARSE');
  879. }
  880. throw e;
  881. }
  882. }
  883. }
  884. return data;
  885. }],
  886. /**
  887. * A timeout in milliseconds to abort a request. If set to 0 (default) a
  888. * timeout is not created.
  889. */
  890. timeout: 0,
  891. xsrfCookieName: 'XSRF-TOKEN',
  892. xsrfHeaderName: 'X-XSRF-TOKEN',
  893. maxContentLength: -1,
  894. maxBodyLength: -1,
  895. validateStatus: function validateStatus(status) {
  896. return status >= 200 && status < 300;
  897. }
  898. };
  899. defaults.headers = {
  900. common: {
  901. 'Accept': 'application/json, text/plain, */*'
  902. }
  903. };
  904. utils.forEach(['delete', 'get', 'head'], function forEachMethodNoData(method) {
  905. defaults.headers[method] = {};
  906. });
  907. utils.forEach(['post', 'put', 'patch'], function forEachMethodWithData(method) {
  908. defaults.headers[method] = utils.merge(DEFAULT_CONTENT_TYPE);
  909. });
  910. module.exports = defaults;
  911. /***/ }),
  912. /***/ "./node_modules/axios/lib/helpers/bind.js":
  913. /*!************************************************!*\
  914. !*** ./node_modules/axios/lib/helpers/bind.js ***!
  915. \************************************************/
  916. /***/ ((module) => {
  917. "use strict";
  918. module.exports = function bind(fn, thisArg) {
  919. return function wrap() {
  920. var args = new Array(arguments.length);
  921. for (var i = 0; i < args.length; i++) {
  922. args[i] = arguments[i];
  923. }
  924. return fn.apply(thisArg, args);
  925. };
  926. };
  927. /***/ }),
  928. /***/ "./node_modules/axios/lib/helpers/buildURL.js":
  929. /*!****************************************************!*\
  930. !*** ./node_modules/axios/lib/helpers/buildURL.js ***!
  931. \****************************************************/
  932. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  933. "use strict";
  934. var utils = __webpack_require__(/*! ./../utils */ "./node_modules/axios/lib/utils.js");
  935. function encode(val) {
  936. return encodeURIComponent(val).
  937. replace(/%3A/gi, ':').
  938. replace(/%24/g, '$').
  939. replace(/%2C/gi, ',').
  940. replace(/%20/g, '+').
  941. replace(/%5B/gi, '[').
  942. replace(/%5D/gi, ']');
  943. }
  944. /**
  945. * Build a URL by appending params to the end
  946. *
  947. * @param {string} url The base of the url (e.g., http://www.google.com)
  948. * @param {object} [params] The params to be appended
  949. * @returns {string} The formatted url
  950. */
  951. module.exports = function buildURL(url, params, paramsSerializer) {
  952. /*eslint no-param-reassign:0*/
  953. if (!params) {
  954. return url;
  955. }
  956. var serializedParams;
  957. if (paramsSerializer) {
  958. serializedParams = paramsSerializer(params);
  959. } else if (utils.isURLSearchParams(params)) {
  960. serializedParams = params.toString();
  961. } else {
  962. var parts = [];
  963. utils.forEach(params, function serialize(val, key) {
  964. if (val === null || typeof val === 'undefined') {
  965. return;
  966. }
  967. if (utils.isArray(val)) {
  968. key = key + '[]';
  969. } else {
  970. val = [val];
  971. }
  972. utils.forEach(val, function parseValue(v) {
  973. if (utils.isDate(v)) {
  974. v = v.toISOString();
  975. } else if (utils.isObject(v)) {
  976. v = JSON.stringify(v);
  977. }
  978. parts.push(encode(key) + '=' + encode(v));
  979. });
  980. });
  981. serializedParams = parts.join('&');
  982. }
  983. if (serializedParams) {
  984. var hashmarkIndex = url.indexOf('#');
  985. if (hashmarkIndex !== -1) {
  986. url = url.slice(0, hashmarkIndex);
  987. }
  988. url += (url.indexOf('?') === -1 ? '?' : '&') + serializedParams;
  989. }
  990. return url;
  991. };
  992. /***/ }),
  993. /***/ "./node_modules/axios/lib/helpers/combineURLs.js":
  994. /*!*******************************************************!*\
  995. !*** ./node_modules/axios/lib/helpers/combineURLs.js ***!
  996. \*******************************************************/
  997. /***/ ((module) => {
  998. "use strict";
  999. /**
  1000. * Creates a new URL by combining the specified URLs
  1001. *
  1002. * @param {string} baseURL The base URL
  1003. * @param {string} relativeURL The relative URL
  1004. * @returns {string} The combined URL
  1005. */
  1006. module.exports = function combineURLs(baseURL, relativeURL) {
  1007. return relativeURL
  1008. ? baseURL.replace(/\/+$/, '') + '/' + relativeURL.replace(/^\/+/, '')
  1009. : baseURL;
  1010. };
  1011. /***/ }),
  1012. /***/ "./node_modules/axios/lib/helpers/cookies.js":
  1013. /*!***************************************************!*\
  1014. !*** ./node_modules/axios/lib/helpers/cookies.js ***!
  1015. \***************************************************/
  1016. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  1017. "use strict";
  1018. var utils = __webpack_require__(/*! ./../utils */ "./node_modules/axios/lib/utils.js");
  1019. module.exports = (
  1020. utils.isStandardBrowserEnv() ?
  1021. // Standard browser envs support document.cookie
  1022. (function standardBrowserEnv() {
  1023. return {
  1024. write: function write(name, value, expires, path, domain, secure) {
  1025. var cookie = [];
  1026. cookie.push(name + '=' + encodeURIComponent(value));
  1027. if (utils.isNumber(expires)) {
  1028. cookie.push('expires=' + new Date(expires).toGMTString());
  1029. }
  1030. if (utils.isString(path)) {
  1031. cookie.push('path=' + path);
  1032. }
  1033. if (utils.isString(domain)) {
  1034. cookie.push('domain=' + domain);
  1035. }
  1036. if (secure === true) {
  1037. cookie.push('secure');
  1038. }
  1039. document.cookie = cookie.join('; ');
  1040. },
  1041. read: function read(name) {
  1042. var match = document.cookie.match(new RegExp('(^|;\\s*)(' + name + ')=([^;]*)'));
  1043. return (match ? decodeURIComponent(match[3]) : null);
  1044. },
  1045. remove: function remove(name) {
  1046. this.write(name, '', Date.now() - 86400000);
  1047. }
  1048. };
  1049. })() :
  1050. // Non standard browser env (web workers, react-native) lack needed support.
  1051. (function nonStandardBrowserEnv() {
  1052. return {
  1053. write: function write() {},
  1054. read: function read() { return null; },
  1055. remove: function remove() {}
  1056. };
  1057. })()
  1058. );
  1059. /***/ }),
  1060. /***/ "./node_modules/axios/lib/helpers/isAbsoluteURL.js":
  1061. /*!*********************************************************!*\
  1062. !*** ./node_modules/axios/lib/helpers/isAbsoluteURL.js ***!
  1063. \*********************************************************/
  1064. /***/ ((module) => {
  1065. "use strict";
  1066. /**
  1067. * Determines whether the specified URL is absolute
  1068. *
  1069. * @param {string} url The URL to test
  1070. * @returns {boolean} True if the specified URL is absolute, otherwise false
  1071. */
  1072. module.exports = function isAbsoluteURL(url) {
  1073. // A URL is considered absolute if it begins with "<scheme>://" or "//" (protocol-relative URL).
  1074. // RFC 3986 defines scheme name as a sequence of characters beginning with a letter and followed
  1075. // by any combination of letters, digits, plus, period, or hyphen.
  1076. return /^([a-z][a-z\d\+\-\.]*:)?\/\//i.test(url);
  1077. };
  1078. /***/ }),
  1079. /***/ "./node_modules/axios/lib/helpers/isAxiosError.js":
  1080. /*!********************************************************!*\
  1081. !*** ./node_modules/axios/lib/helpers/isAxiosError.js ***!
  1082. \********************************************************/
  1083. /***/ ((module) => {
  1084. "use strict";
  1085. /**
  1086. * Determines whether the payload is an error thrown by Axios
  1087. *
  1088. * @param {*} payload The value to test
  1089. * @returns {boolean} True if the payload is an error thrown by Axios, otherwise false
  1090. */
  1091. module.exports = function isAxiosError(payload) {
  1092. return (typeof payload === 'object') && (payload.isAxiosError === true);
  1093. };
  1094. /***/ }),
  1095. /***/ "./node_modules/axios/lib/helpers/isURLSameOrigin.js":
  1096. /*!***********************************************************!*\
  1097. !*** ./node_modules/axios/lib/helpers/isURLSameOrigin.js ***!
  1098. \***********************************************************/
  1099. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  1100. "use strict";
  1101. var utils = __webpack_require__(/*! ./../utils */ "./node_modules/axios/lib/utils.js");
  1102. module.exports = (
  1103. utils.isStandardBrowserEnv() ?
  1104. // Standard browser envs have full support of the APIs needed to test
  1105. // whether the request URL is of the same origin as current location.
  1106. (function standardBrowserEnv() {
  1107. var msie = /(msie|trident)/i.test(navigator.userAgent);
  1108. var urlParsingNode = document.createElement('a');
  1109. var originURL;
  1110. /**
  1111. * Parse a URL to discover it's components
  1112. *
  1113. * @param {String} url The URL to be parsed
  1114. * @returns {Object}
  1115. */
  1116. function resolveURL(url) {
  1117. var href = url;
  1118. if (msie) {
  1119. // IE needs attribute set twice to normalize properties
  1120. urlParsingNode.setAttribute('href', href);
  1121. href = urlParsingNode.href;
  1122. }
  1123. urlParsingNode.setAttribute('href', href);
  1124. // urlParsingNode provides the UrlUtils interface - http://url.spec.whatwg.org/#urlutils
  1125. return {
  1126. href: urlParsingNode.href,
  1127. protocol: urlParsingNode.protocol ? urlParsingNode.protocol.replace(/:$/, '') : '',
  1128. host: urlParsingNode.host,
  1129. search: urlParsingNode.search ? urlParsingNode.search.replace(/^\?/, '') : '',
  1130. hash: urlParsingNode.hash ? urlParsingNode.hash.replace(/^#/, '') : '',
  1131. hostname: urlParsingNode.hostname,
  1132. port: urlParsingNode.port,
  1133. pathname: (urlParsingNode.pathname.charAt(0) === '/') ?
  1134. urlParsingNode.pathname :
  1135. '/' + urlParsingNode.pathname
  1136. };
  1137. }
  1138. originURL = resolveURL(window.location.href);
  1139. /**
  1140. * Determine if a URL shares the same origin as the current location
  1141. *
  1142. * @param {String} requestURL The URL to test
  1143. * @returns {boolean} True if URL shares the same origin, otherwise false
  1144. */
  1145. return function isURLSameOrigin(requestURL) {
  1146. var parsed = (utils.isString(requestURL)) ? resolveURL(requestURL) : requestURL;
  1147. return (parsed.protocol === originURL.protocol &&
  1148. parsed.host === originURL.host);
  1149. };
  1150. })() :
  1151. // Non standard browser envs (web workers, react-native) lack needed support.
  1152. (function nonStandardBrowserEnv() {
  1153. return function isURLSameOrigin() {
  1154. return true;
  1155. };
  1156. })()
  1157. );
  1158. /***/ }),
  1159. /***/ "./node_modules/axios/lib/helpers/normalizeHeaderName.js":
  1160. /*!***************************************************************!*\
  1161. !*** ./node_modules/axios/lib/helpers/normalizeHeaderName.js ***!
  1162. \***************************************************************/
  1163. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  1164. "use strict";
  1165. var utils = __webpack_require__(/*! ../utils */ "./node_modules/axios/lib/utils.js");
  1166. module.exports = function normalizeHeaderName(headers, normalizedName) {
  1167. utils.forEach(headers, function processHeader(value, name) {
  1168. if (name !== normalizedName && name.toUpperCase() === normalizedName.toUpperCase()) {
  1169. headers[normalizedName] = value;
  1170. delete headers[name];
  1171. }
  1172. });
  1173. };
  1174. /***/ }),
  1175. /***/ "./node_modules/axios/lib/helpers/parseHeaders.js":
  1176. /*!********************************************************!*\
  1177. !*** ./node_modules/axios/lib/helpers/parseHeaders.js ***!
  1178. \********************************************************/
  1179. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  1180. "use strict";
  1181. var utils = __webpack_require__(/*! ./../utils */ "./node_modules/axios/lib/utils.js");
  1182. // Headers whose duplicates are ignored by node
  1183. // c.f. https://nodejs.org/api/http.html#http_message_headers
  1184. var ignoreDuplicateOf = [
  1185. 'age', 'authorization', 'content-length', 'content-type', 'etag',
  1186. 'expires', 'from', 'host', 'if-modified-since', 'if-unmodified-since',
  1187. 'last-modified', 'location', 'max-forwards', 'proxy-authorization',
  1188. 'referer', 'retry-after', 'user-agent'
  1189. ];
  1190. /**
  1191. * Parse headers into an object
  1192. *
  1193. * ```
  1194. * Date: Wed, 27 Aug 2014 08:58:49 GMT
  1195. * Content-Type: application/json
  1196. * Connection: keep-alive
  1197. * Transfer-Encoding: chunked
  1198. * ```
  1199. *
  1200. * @param {String} headers Headers needing to be parsed
  1201. * @returns {Object} Headers parsed into an object
  1202. */
  1203. module.exports = function parseHeaders(headers) {
  1204. var parsed = {};
  1205. var key;
  1206. var val;
  1207. var i;
  1208. if (!headers) { return parsed; }
  1209. utils.forEach(headers.split('\n'), function parser(line) {
  1210. i = line.indexOf(':');
  1211. key = utils.trim(line.substr(0, i)).toLowerCase();
  1212. val = utils.trim(line.substr(i + 1));
  1213. if (key) {
  1214. if (parsed[key] && ignoreDuplicateOf.indexOf(key) >= 0) {
  1215. return;
  1216. }
  1217. if (key === 'set-cookie') {
  1218. parsed[key] = (parsed[key] ? parsed[key] : []).concat([val]);
  1219. } else {
  1220. parsed[key] = parsed[key] ? parsed[key] + ', ' + val : val;
  1221. }
  1222. }
  1223. });
  1224. return parsed;
  1225. };
  1226. /***/ }),
  1227. /***/ "./node_modules/axios/lib/helpers/spread.js":
  1228. /*!**************************************************!*\
  1229. !*** ./node_modules/axios/lib/helpers/spread.js ***!
  1230. \**************************************************/
  1231. /***/ ((module) => {
  1232. "use strict";
  1233. /**
  1234. * Syntactic sugar for invoking a function and expanding an array for arguments.
  1235. *
  1236. * Common use case would be to use `Function.prototype.apply`.
  1237. *
  1238. * ```js
  1239. * function f(x, y, z) {}
  1240. * var args = [1, 2, 3];
  1241. * f.apply(null, args);
  1242. * ```
  1243. *
  1244. * With `spread` this example can be re-written.
  1245. *
  1246. * ```js
  1247. * spread(function(x, y, z) {})([1, 2, 3]);
  1248. * ```
  1249. *
  1250. * @param {Function} callback
  1251. * @returns {Function}
  1252. */
  1253. module.exports = function spread(callback) {
  1254. return function wrap(arr) {
  1255. return callback.apply(null, arr);
  1256. };
  1257. };
  1258. /***/ }),
  1259. /***/ "./node_modules/axios/lib/helpers/validator.js":
  1260. /*!*****************************************************!*\
  1261. !*** ./node_modules/axios/lib/helpers/validator.js ***!
  1262. \*****************************************************/
  1263. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  1264. "use strict";
  1265. var pkg = __webpack_require__(/*! ./../../package.json */ "./node_modules/axios/package.json");
  1266. var validators = {};
  1267. // eslint-disable-next-line func-names
  1268. ['object', 'boolean', 'number', 'function', 'string', 'symbol'].forEach(function(type, i) {
  1269. validators[type] = function validator(thing) {
  1270. return typeof thing === type || 'a' + (i < 1 ? 'n ' : ' ') + type;
  1271. };
  1272. });
  1273. var deprecatedWarnings = {};
  1274. var currentVerArr = pkg.version.split('.');
  1275. /**
  1276. * Compare package versions
  1277. * @param {string} version
  1278. * @param {string?} thanVersion
  1279. * @returns {boolean}
  1280. */
  1281. function isOlderVersion(version, thanVersion) {
  1282. var pkgVersionArr = thanVersion ? thanVersion.split('.') : currentVerArr;
  1283. var destVer = version.split('.');
  1284. for (var i = 0; i < 3; i++) {
  1285. if (pkgVersionArr[i] > destVer[i]) {
  1286. return true;
  1287. } else if (pkgVersionArr[i] < destVer[i]) {
  1288. return false;
  1289. }
  1290. }
  1291. return false;
  1292. }
  1293. /**
  1294. * Transitional option validator
  1295. * @param {function|boolean?} validator
  1296. * @param {string?} version
  1297. * @param {string} message
  1298. * @returns {function}
  1299. */
  1300. validators.transitional = function transitional(validator, version, message) {
  1301. var isDeprecated = version && isOlderVersion(version);
  1302. function formatMessage(opt, desc) {
  1303. return '[Axios v' + pkg.version + '] Transitional option \'' + opt + '\'' + desc + (message ? '. ' + message : '');
  1304. }
  1305. // eslint-disable-next-line func-names
  1306. return function(value, opt, opts) {
  1307. if (validator === false) {
  1308. throw new Error(formatMessage(opt, ' has been removed in ' + version));
  1309. }
  1310. if (isDeprecated && !deprecatedWarnings[opt]) {
  1311. deprecatedWarnings[opt] = true;
  1312. // eslint-disable-next-line no-console
  1313. console.warn(
  1314. formatMessage(
  1315. opt,
  1316. ' has been deprecated since v' + version + ' and will be removed in the near future'
  1317. )
  1318. );
  1319. }
  1320. return validator ? validator(value, opt, opts) : true;
  1321. };
  1322. };
  1323. /**
  1324. * Assert object's properties type
  1325. * @param {object} options
  1326. * @param {object} schema
  1327. * @param {boolean?} allowUnknown
  1328. */
  1329. function assertOptions(options, schema, allowUnknown) {
  1330. if (typeof options !== 'object') {
  1331. throw new TypeError('options must be an object');
  1332. }
  1333. var keys = Object.keys(options);
  1334. var i = keys.length;
  1335. while (i-- > 0) {
  1336. var opt = keys[i];
  1337. var validator = schema[opt];
  1338. if (validator) {
  1339. var value = options[opt];
  1340. var result = value === undefined || validator(value, opt, options);
  1341. if (result !== true) {
  1342. throw new TypeError('option ' + opt + ' must be ' + result);
  1343. }
  1344. continue;
  1345. }
  1346. if (allowUnknown !== true) {
  1347. throw Error('Unknown option ' + opt);
  1348. }
  1349. }
  1350. }
  1351. module.exports = {
  1352. isOlderVersion: isOlderVersion,
  1353. assertOptions: assertOptions,
  1354. validators: validators
  1355. };
  1356. /***/ }),
  1357. /***/ "./node_modules/axios/lib/utils.js":
  1358. /*!*****************************************!*\
  1359. !*** ./node_modules/axios/lib/utils.js ***!
  1360. \*****************************************/
  1361. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  1362. "use strict";
  1363. var bind = __webpack_require__(/*! ./helpers/bind */ "./node_modules/axios/lib/helpers/bind.js");
  1364. // utils is a library of generic helper functions non-specific to axios
  1365. var toString = Object.prototype.toString;
  1366. /**
  1367. * Determine if a value is an Array
  1368. *
  1369. * @param {Object} val The value to test
  1370. * @returns {boolean} True if value is an Array, otherwise false
  1371. */
  1372. function isArray(val) {
  1373. return toString.call(val) === '[object Array]';
  1374. }
  1375. /**
  1376. * Determine if a value is undefined
  1377. *
  1378. * @param {Object} val The value to test
  1379. * @returns {boolean} True if the value is undefined, otherwise false
  1380. */
  1381. function isUndefined(val) {
  1382. return typeof val === 'undefined';
  1383. }
  1384. /**
  1385. * Determine if a value is a Buffer
  1386. *
  1387. * @param {Object} val The value to test
  1388. * @returns {boolean} True if value is a Buffer, otherwise false
  1389. */
  1390. function isBuffer(val) {
  1391. return val !== null && !isUndefined(val) && val.constructor !== null && !isUndefined(val.constructor)
  1392. && typeof val.constructor.isBuffer === 'function' && val.constructor.isBuffer(val);
  1393. }
  1394. /**
  1395. * Determine if a value is an ArrayBuffer
  1396. *
  1397. * @param {Object} val The value to test
  1398. * @returns {boolean} True if value is an ArrayBuffer, otherwise false
  1399. */
  1400. function isArrayBuffer(val) {
  1401. return toString.call(val) === '[object ArrayBuffer]';
  1402. }
  1403. /**
  1404. * Determine if a value is a FormData
  1405. *
  1406. * @param {Object} val The value to test
  1407. * @returns {boolean} True if value is an FormData, otherwise false
  1408. */
  1409. function isFormData(val) {
  1410. return (typeof FormData !== 'undefined') && (val instanceof FormData);
  1411. }
  1412. /**
  1413. * Determine if a value is a view on an ArrayBuffer
  1414. *
  1415. * @param {Object} val The value to test
  1416. * @returns {boolean} True if value is a view on an ArrayBuffer, otherwise false
  1417. */
  1418. function isArrayBufferView(val) {
  1419. var result;
  1420. if ((typeof ArrayBuffer !== 'undefined') && (ArrayBuffer.isView)) {
  1421. result = ArrayBuffer.isView(val);
  1422. } else {
  1423. result = (val) && (val.buffer) && (val.buffer instanceof ArrayBuffer);
  1424. }
  1425. return result;
  1426. }
  1427. /**
  1428. * Determine if a value is a String
  1429. *
  1430. * @param {Object} val The value to test
  1431. * @returns {boolean} True if value is a String, otherwise false
  1432. */
  1433. function isString(val) {
  1434. return typeof val === 'string';
  1435. }
  1436. /**
  1437. * Determine if a value is a Number
  1438. *
  1439. * @param {Object} val The value to test
  1440. * @returns {boolean} True if value is a Number, otherwise false
  1441. */
  1442. function isNumber(val) {
  1443. return typeof val === 'number';
  1444. }
  1445. /**
  1446. * Determine if a value is an Object
  1447. *
  1448. * @param {Object} val The value to test
  1449. * @returns {boolean} True if value is an Object, otherwise false
  1450. */
  1451. function isObject(val) {
  1452. return val !== null && typeof val === 'object';
  1453. }
  1454. /**
  1455. * Determine if a value is a plain Object
  1456. *
  1457. * @param {Object} val The value to test
  1458. * @return {boolean} True if value is a plain Object, otherwise false
  1459. */
  1460. function isPlainObject(val) {
  1461. if (toString.call(val) !== '[object Object]') {
  1462. return false;
  1463. }
  1464. var prototype = Object.getPrototypeOf(val);
  1465. return prototype === null || prototype === Object.prototype;
  1466. }
  1467. /**
  1468. * Determine if a value is a Date
  1469. *
  1470. * @param {Object} val The value to test
  1471. * @returns {boolean} True if value is a Date, otherwise false
  1472. */
  1473. function isDate(val) {
  1474. return toString.call(val) === '[object Date]';
  1475. }
  1476. /**
  1477. * Determine if a value is a File
  1478. *
  1479. * @param {Object} val The value to test
  1480. * @returns {boolean} True if value is a File, otherwise false
  1481. */
  1482. function isFile(val) {
  1483. return toString.call(val) === '[object File]';
  1484. }
  1485. /**
  1486. * Determine if a value is a Blob
  1487. *
  1488. * @param {Object} val The value to test
  1489. * @returns {boolean} True if value is a Blob, otherwise false
  1490. */
  1491. function isBlob(val) {
  1492. return toString.call(val) === '[object Blob]';
  1493. }
  1494. /**
  1495. * Determine if a value is a Function
  1496. *
  1497. * @param {Object} val The value to test
  1498. * @returns {boolean} True if value is a Function, otherwise false
  1499. */
  1500. function isFunction(val) {
  1501. return toString.call(val) === '[object Function]';
  1502. }
  1503. /**
  1504. * Determine if a value is a Stream
  1505. *
  1506. * @param {Object} val The value to test
  1507. * @returns {boolean} True if value is a Stream, otherwise false
  1508. */
  1509. function isStream(val) {
  1510. return isObject(val) && isFunction(val.pipe);
  1511. }
  1512. /**
  1513. * Determine if a value is a URLSearchParams object
  1514. *
  1515. * @param {Object} val The value to test
  1516. * @returns {boolean} True if value is a URLSearchParams object, otherwise false
  1517. */
  1518. function isURLSearchParams(val) {
  1519. return typeof URLSearchParams !== 'undefined' && val instanceof URLSearchParams;
  1520. }
  1521. /**
  1522. * Trim excess whitespace off the beginning and end of a string
  1523. *
  1524. * @param {String} str The String to trim
  1525. * @returns {String} The String freed of excess whitespace
  1526. */
  1527. function trim(str) {
  1528. return str.trim ? str.trim() : str.replace(/^\s+|\s+$/g, '');
  1529. }
  1530. /**
  1531. * Determine if we're running in a standard browser environment
  1532. *
  1533. * This allows axios to run in a web worker, and react-native.
  1534. * Both environments support XMLHttpRequest, but not fully standard globals.
  1535. *
  1536. * web workers:
  1537. * typeof window -> undefined
  1538. * typeof document -> undefined
  1539. *
  1540. * react-native:
  1541. * navigator.product -> 'ReactNative'
  1542. * nativescript
  1543. * navigator.product -> 'NativeScript' or 'NS'
  1544. */
  1545. function isStandardBrowserEnv() {
  1546. if (typeof navigator !== 'undefined' && (navigator.product === 'ReactNative' ||
  1547. navigator.product === 'NativeScript' ||
  1548. navigator.product === 'NS')) {
  1549. return false;
  1550. }
  1551. return (
  1552. typeof window !== 'undefined' &&
  1553. typeof document !== 'undefined'
  1554. );
  1555. }
  1556. /**
  1557. * Iterate over an Array or an Object invoking a function for each item.
  1558. *
  1559. * If `obj` is an Array callback will be called passing
  1560. * the value, index, and complete array for each item.
  1561. *
  1562. * If 'obj' is an Object callback will be called passing
  1563. * the value, key, and complete object for each property.
  1564. *
  1565. * @param {Object|Array} obj The object to iterate
  1566. * @param {Function} fn The callback to invoke for each item
  1567. */
  1568. function forEach(obj, fn) {
  1569. // Don't bother if no value provided
  1570. if (obj === null || typeof obj === 'undefined') {
  1571. return;
  1572. }
  1573. // Force an array if not already something iterable
  1574. if (typeof obj !== 'object') {
  1575. /*eslint no-param-reassign:0*/
  1576. obj = [obj];
  1577. }
  1578. if (isArray(obj)) {
  1579. // Iterate over array values
  1580. for (var i = 0, l = obj.length; i < l; i++) {
  1581. fn.call(null, obj[i], i, obj);
  1582. }
  1583. } else {
  1584. // Iterate over object keys
  1585. for (var key in obj) {
  1586. if (Object.prototype.hasOwnProperty.call(obj, key)) {
  1587. fn.call(null, obj[key], key, obj);
  1588. }
  1589. }
  1590. }
  1591. }
  1592. /**
  1593. * Accepts varargs expecting each argument to be an object, then
  1594. * immutably merges the properties of each object and returns result.
  1595. *
  1596. * When multiple objects contain the same key the later object in
  1597. * the arguments list will take precedence.
  1598. *
  1599. * Example:
  1600. *
  1601. * ```js
  1602. * var result = merge({foo: 123}, {foo: 456});
  1603. * console.log(result.foo); // outputs 456
  1604. * ```
  1605. *
  1606. * @param {Object} obj1 Object to merge
  1607. * @returns {Object} Result of all merge properties
  1608. */
  1609. function merge(/* obj1, obj2, obj3, ... */) {
  1610. var result = {};
  1611. function assignValue(val, key) {
  1612. if (isPlainObject(result[key]) && isPlainObject(val)) {
  1613. result[key] = merge(result[key], val);
  1614. } else if (isPlainObject(val)) {
  1615. result[key] = merge({}, val);
  1616. } else if (isArray(val)) {
  1617. result[key] = val.slice();
  1618. } else {
  1619. result[key] = val;
  1620. }
  1621. }
  1622. for (var i = 0, l = arguments.length; i < l; i++) {
  1623. forEach(arguments[i], assignValue);
  1624. }
  1625. return result;
  1626. }
  1627. /**
  1628. * Extends object a by mutably adding to it the properties of object b.
  1629. *
  1630. * @param {Object} a The object to be extended
  1631. * @param {Object} b The object to copy properties from
  1632. * @param {Object} thisArg The object to bind function to
  1633. * @return {Object} The resulting value of object a
  1634. */
  1635. function extend(a, b, thisArg) {
  1636. forEach(b, function assignValue(val, key) {
  1637. if (thisArg && typeof val === 'function') {
  1638. a[key] = bind(val, thisArg);
  1639. } else {
  1640. a[key] = val;
  1641. }
  1642. });
  1643. return a;
  1644. }
  1645. /**
  1646. * Remove byte order marker. This catches EF BB BF (the UTF-8 BOM)
  1647. *
  1648. * @param {string} content with BOM
  1649. * @return {string} content value without BOM
  1650. */
  1651. function stripBOM(content) {
  1652. if (content.charCodeAt(0) === 0xFEFF) {
  1653. content = content.slice(1);
  1654. }
  1655. return content;
  1656. }
  1657. module.exports = {
  1658. isArray: isArray,
  1659. isArrayBuffer: isArrayBuffer,
  1660. isBuffer: isBuffer,
  1661. isFormData: isFormData,
  1662. isArrayBufferView: isArrayBufferView,
  1663. isString: isString,
  1664. isNumber: isNumber,
  1665. isObject: isObject,
  1666. isPlainObject: isPlainObject,
  1667. isUndefined: isUndefined,
  1668. isDate: isDate,
  1669. isFile: isFile,
  1670. isBlob: isBlob,
  1671. isFunction: isFunction,
  1672. isStream: isStream,
  1673. isURLSearchParams: isURLSearchParams,
  1674. isStandardBrowserEnv: isStandardBrowserEnv,
  1675. forEach: forEach,
  1676. merge: merge,
  1677. extend: extend,
  1678. trim: trim,
  1679. stripBOM: stripBOM
  1680. };
  1681. /***/ }),
  1682. /***/ "./resources/js/app.js":
  1683. /*!*****************************!*\
  1684. !*** ./resources/js/app.js ***!
  1685. \*****************************/
  1686. /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => {
  1687. __webpack_require__(/*! ./bootstrap */ "./resources/js/bootstrap.js");
  1688. /***/ }),
  1689. /***/ "./resources/js/bootstrap.js":
  1690. /*!***********************************!*\
  1691. !*** ./resources/js/bootstrap.js ***!
  1692. \***********************************/
  1693. /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => {
  1694. window._ = __webpack_require__(/*! lodash */ "./node_modules/lodash/lodash.js");
  1695. /**
  1696. * We'll load the axios HTTP library which allows us to easily issue requests
  1697. * to our Laravel back-end. This library automatically handles sending the
  1698. * CSRF token as a header based on the value of the "XSRF" token cookie.
  1699. */
  1700. window.axios = __webpack_require__(/*! axios */ "./node_modules/axios/index.js");
  1701. window.axios.defaults.headers.common['X-Requested-With'] = 'XMLHttpRequest';
  1702. /**
  1703. * Echo exposes an expressive API for subscribing to channels and listening
  1704. * for events that are broadcast by Laravel. Echo and event broadcasting
  1705. * allows your team to easily build robust real-time web applications.
  1706. */
  1707. // import Echo from 'laravel-echo';
  1708. // window.Pusher = require('pusher-js');
  1709. // window.Echo = new Echo({
  1710. // broadcaster: 'pusher',
  1711. // key: process.env.MIX_PUSHER_APP_KEY,
  1712. // cluster: process.env.MIX_PUSHER_APP_CLUSTER,
  1713. // forceTLS: true
  1714. // });
  1715. /***/ }),
  1716. /***/ "./node_modules/lodash/lodash.js":
  1717. /*!***************************************!*\
  1718. !*** ./node_modules/lodash/lodash.js ***!
  1719. \***************************************/
  1720. /***/ (function(module, exports, __webpack_require__) {
  1721. /* module decorator */ module = __webpack_require__.nmd(module);
  1722. var __WEBPACK_AMD_DEFINE_RESULT__;/**
  1723. * @license
  1724. * Lodash <https://lodash.com/>
  1725. * Copyright OpenJS Foundation and other contributors <https://openjsf.org/>
  1726. * Released under MIT license <https://lodash.com/license>
  1727. * Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
  1728. * Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
  1729. */
  1730. ;(function() {
  1731. /** Used as a safe reference for `undefined` in pre-ES5 environments. */
  1732. var undefined;
  1733. /** Used as the semantic version number. */
  1734. var VERSION = '4.17.21';
  1735. /** Used as the size to enable large array optimizations. */
  1736. var LARGE_ARRAY_SIZE = 200;
  1737. /** Error message constants. */
  1738. var CORE_ERROR_TEXT = 'Unsupported core-js use. Try https://npms.io/search?q=ponyfill.',
  1739. FUNC_ERROR_TEXT = 'Expected a function',
  1740. INVALID_TEMPL_VAR_ERROR_TEXT = 'Invalid `variable` option passed into `_.template`';
  1741. /** Used to stand-in for `undefined` hash values. */
  1742. var HASH_UNDEFINED = '__lodash_hash_undefined__';
  1743. /** Used as the maximum memoize cache size. */
  1744. var MAX_MEMOIZE_SIZE = 500;
  1745. /** Used as the internal argument placeholder. */
  1746. var PLACEHOLDER = '__lodash_placeholder__';
  1747. /** Used to compose bitmasks for cloning. */
  1748. var CLONE_DEEP_FLAG = 1,
  1749. CLONE_FLAT_FLAG = 2,
  1750. CLONE_SYMBOLS_FLAG = 4;
  1751. /** Used to compose bitmasks for value comparisons. */
  1752. var COMPARE_PARTIAL_FLAG = 1,
  1753. COMPARE_UNORDERED_FLAG = 2;
  1754. /** Used to compose bitmasks for function metadata. */
  1755. var WRAP_BIND_FLAG = 1,
  1756. WRAP_BIND_KEY_FLAG = 2,
  1757. WRAP_CURRY_BOUND_FLAG = 4,
  1758. WRAP_CURRY_FLAG = 8,
  1759. WRAP_CURRY_RIGHT_FLAG = 16,
  1760. WRAP_PARTIAL_FLAG = 32,
  1761. WRAP_PARTIAL_RIGHT_FLAG = 64,
  1762. WRAP_ARY_FLAG = 128,
  1763. WRAP_REARG_FLAG = 256,
  1764. WRAP_FLIP_FLAG = 512;
  1765. /** Used as default options for `_.truncate`. */
  1766. var DEFAULT_TRUNC_LENGTH = 30,
  1767. DEFAULT_TRUNC_OMISSION = '...';
  1768. /** Used to detect hot functions by number of calls within a span of milliseconds. */
  1769. var HOT_COUNT = 800,
  1770. HOT_SPAN = 16;
  1771. /** Used to indicate the type of lazy iteratees. */
  1772. var LAZY_FILTER_FLAG = 1,
  1773. LAZY_MAP_FLAG = 2,
  1774. LAZY_WHILE_FLAG = 3;
  1775. /** Used as references for various `Number` constants. */
  1776. var INFINITY = 1 / 0,
  1777. MAX_SAFE_INTEGER = 9007199254740991,
  1778. MAX_INTEGER = 1.7976931348623157e+308,
  1779. NAN = 0 / 0;
  1780. /** Used as references for the maximum length and index of an array. */
  1781. var MAX_ARRAY_LENGTH = 4294967295,
  1782. MAX_ARRAY_INDEX = MAX_ARRAY_LENGTH - 1,
  1783. HALF_MAX_ARRAY_LENGTH = MAX_ARRAY_LENGTH >>> 1;
  1784. /** Used to associate wrap methods with their bit flags. */
  1785. var wrapFlags = [
  1786. ['ary', WRAP_ARY_FLAG],
  1787. ['bind', WRAP_BIND_FLAG],
  1788. ['bindKey', WRAP_BIND_KEY_FLAG],
  1789. ['curry', WRAP_CURRY_FLAG],
  1790. ['curryRight', WRAP_CURRY_RIGHT_FLAG],
  1791. ['flip', WRAP_FLIP_FLAG],
  1792. ['partial', WRAP_PARTIAL_FLAG],
  1793. ['partialRight', WRAP_PARTIAL_RIGHT_FLAG],
  1794. ['rearg', WRAP_REARG_FLAG]
  1795. ];
  1796. /** `Object#toString` result references. */
  1797. var argsTag = '[object Arguments]',
  1798. arrayTag = '[object Array]',
  1799. asyncTag = '[object AsyncFunction]',
  1800. boolTag = '[object Boolean]',
  1801. dateTag = '[object Date]',
  1802. domExcTag = '[object DOMException]',
  1803. errorTag = '[object Error]',
  1804. funcTag = '[object Function]',
  1805. genTag = '[object GeneratorFunction]',
  1806. mapTag = '[object Map]',
  1807. numberTag = '[object Number]',
  1808. nullTag = '[object Null]',
  1809. objectTag = '[object Object]',
  1810. promiseTag = '[object Promise]',
  1811. proxyTag = '[object Proxy]',
  1812. regexpTag = '[object RegExp]',
  1813. setTag = '[object Set]',
  1814. stringTag = '[object String]',
  1815. symbolTag = '[object Symbol]',
  1816. undefinedTag = '[object Undefined]',
  1817. weakMapTag = '[object WeakMap]',
  1818. weakSetTag = '[object WeakSet]';
  1819. var arrayBufferTag = '[object ArrayBuffer]',
  1820. dataViewTag = '[object DataView]',
  1821. float32Tag = '[object Float32Array]',
  1822. float64Tag = '[object Float64Array]',
  1823. int8Tag = '[object Int8Array]',
  1824. int16Tag = '[object Int16Array]',
  1825. int32Tag = '[object Int32Array]',
  1826. uint8Tag = '[object Uint8Array]',
  1827. uint8ClampedTag = '[object Uint8ClampedArray]',
  1828. uint16Tag = '[object Uint16Array]',
  1829. uint32Tag = '[object Uint32Array]';
  1830. /** Used to match empty string literals in compiled template source. */
  1831. var reEmptyStringLeading = /\b__p \+= '';/g,
  1832. reEmptyStringMiddle = /\b(__p \+=) '' \+/g,
  1833. reEmptyStringTrailing = /(__e\(.*?\)|\b__t\)) \+\n'';/g;
  1834. /** Used to match HTML entities and HTML characters. */
  1835. var reEscapedHtml = /&(?:amp|lt|gt|quot|#39);/g,
  1836. reUnescapedHtml = /[&<>"']/g,
  1837. reHasEscapedHtml = RegExp(reEscapedHtml.source),
  1838. reHasUnescapedHtml = RegExp(reUnescapedHtml.source);
  1839. /** Used to match template delimiters. */
  1840. var reEscape = /<%-([\s\S]+?)%>/g,
  1841. reEvaluate = /<%([\s\S]+?)%>/g,
  1842. reInterpolate = /<%=([\s\S]+?)%>/g;
  1843. /** Used to match property names within property paths. */
  1844. var reIsDeepProp = /\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,
  1845. reIsPlainProp = /^\w*$/,
  1846. rePropName = /[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g;
  1847. /**
  1848. * Used to match `RegExp`
  1849. * [syntax characters](http://ecma-international.org/ecma-262/7.0/#sec-patterns).
  1850. */
  1851. var reRegExpChar = /[\\^$.*+?()[\]{}|]/g,
  1852. reHasRegExpChar = RegExp(reRegExpChar.source);
  1853. /** Used to match leading whitespace. */
  1854. var reTrimStart = /^\s+/;
  1855. /** Used to match a single whitespace character. */
  1856. var reWhitespace = /\s/;
  1857. /** Used to match wrap detail comments. */
  1858. var reWrapComment = /\{(?:\n\/\* \[wrapped with .+\] \*\/)?\n?/,
  1859. reWrapDetails = /\{\n\/\* \[wrapped with (.+)\] \*/,
  1860. reSplitDetails = /,? & /;
  1861. /** Used to match words composed of alphanumeric characters. */
  1862. var reAsciiWord = /[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g;
  1863. /**
  1864. * Used to validate the `validate` option in `_.template` variable.
  1865. *
  1866. * Forbids characters which could potentially change the meaning of the function argument definition:
  1867. * - "()," (modification of function parameters)
  1868. * - "=" (default value)
  1869. * - "[]{}" (destructuring of function parameters)
  1870. * - "/" (beginning of a comment)
  1871. * - whitespace
  1872. */
  1873. var reForbiddenIdentifierChars = /[()=,{}\[\]\/\s]/;
  1874. /** Used to match backslashes in property paths. */
  1875. var reEscapeChar = /\\(\\)?/g;
  1876. /**
  1877. * Used to match
  1878. * [ES template delimiters](http://ecma-international.org/ecma-262/7.0/#sec-template-literal-lexical-components).
  1879. */
  1880. var reEsTemplate = /\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g;
  1881. /** Used to match `RegExp` flags from their coerced string values. */
  1882. var reFlags = /\w*$/;
  1883. /** Used to detect bad signed hexadecimal string values. */
  1884. var reIsBadHex = /^[-+]0x[0-9a-f]+$/i;
  1885. /** Used to detect binary string values. */
  1886. var reIsBinary = /^0b[01]+$/i;
  1887. /** Used to detect host constructors (Safari). */
  1888. var reIsHostCtor = /^\[object .+?Constructor\]$/;
  1889. /** Used to detect octal string values. */
  1890. var reIsOctal = /^0o[0-7]+$/i;
  1891. /** Used to detect unsigned integer values. */
  1892. var reIsUint = /^(?:0|[1-9]\d*)$/;
  1893. /** Used to match Latin Unicode letters (excluding mathematical operators). */
  1894. var reLatin = /[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g;
  1895. /** Used to ensure capturing order of template delimiters. */
  1896. var reNoMatch = /($^)/;
  1897. /** Used to match unescaped characters in compiled string literals. */
  1898. var reUnescapedString = /['\n\r\u2028\u2029\\]/g;
  1899. /** Used to compose unicode character classes. */
  1900. var rsAstralRange = '\\ud800-\\udfff',
  1901. rsComboMarksRange = '\\u0300-\\u036f',
  1902. reComboHalfMarksRange = '\\ufe20-\\ufe2f',
  1903. rsComboSymbolsRange = '\\u20d0-\\u20ff',
  1904. rsComboRange = rsComboMarksRange + reComboHalfMarksRange + rsComboSymbolsRange,
  1905. rsDingbatRange = '\\u2700-\\u27bf',
  1906. rsLowerRange = 'a-z\\xdf-\\xf6\\xf8-\\xff',
  1907. rsMathOpRange = '\\xac\\xb1\\xd7\\xf7',
  1908. rsNonCharRange = '\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf',
  1909. rsPunctuationRange = '\\u2000-\\u206f',
  1910. 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',
  1911. rsUpperRange = 'A-Z\\xc0-\\xd6\\xd8-\\xde',
  1912. rsVarRange = '\\ufe0e\\ufe0f',
  1913. rsBreakRange = rsMathOpRange + rsNonCharRange + rsPunctuationRange + rsSpaceRange;
  1914. /** Used to compose unicode capture groups. */
  1915. var rsApos = "['\u2019]",
  1916. rsAstral = '[' + rsAstralRange + ']',
  1917. rsBreak = '[' + rsBreakRange + ']',
  1918. rsCombo = '[' + rsComboRange + ']',
  1919. rsDigits = '\\d+',
  1920. rsDingbat = '[' + rsDingbatRange + ']',
  1921. rsLower = '[' + rsLowerRange + ']',
  1922. rsMisc = '[^' + rsAstralRange + rsBreakRange + rsDigits + rsDingbatRange + rsLowerRange + rsUpperRange + ']',
  1923. rsFitz = '\\ud83c[\\udffb-\\udfff]',
  1924. rsModifier = '(?:' + rsCombo + '|' + rsFitz + ')',
  1925. rsNonAstral = '[^' + rsAstralRange + ']',
  1926. rsRegional = '(?:\\ud83c[\\udde6-\\uddff]){2}',
  1927. rsSurrPair = '[\\ud800-\\udbff][\\udc00-\\udfff]',
  1928. rsUpper = '[' + rsUpperRange + ']',
  1929. rsZWJ = '\\u200d';
  1930. /** Used to compose unicode regexes. */
  1931. var rsMiscLower = '(?:' + rsLower + '|' + rsMisc + ')',
  1932. rsMiscUpper = '(?:' + rsUpper + '|' + rsMisc + ')',
  1933. rsOptContrLower = '(?:' + rsApos + '(?:d|ll|m|re|s|t|ve))?',
  1934. rsOptContrUpper = '(?:' + rsApos + '(?:D|LL|M|RE|S|T|VE))?',
  1935. reOptMod = rsModifier + '?',
  1936. rsOptVar = '[' + rsVarRange + ']?',
  1937. rsOptJoin = '(?:' + rsZWJ + '(?:' + [rsNonAstral, rsRegional, rsSurrPair].join('|') + ')' + rsOptVar + reOptMod + ')*',
  1938. rsOrdLower = '\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])',
  1939. rsOrdUpper = '\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])',
  1940. rsSeq = rsOptVar + reOptMod + rsOptJoin,
  1941. rsEmoji = '(?:' + [rsDingbat, rsRegional, rsSurrPair].join('|') + ')' + rsSeq,
  1942. rsSymbol = '(?:' + [rsNonAstral + rsCombo + '?', rsCombo, rsRegional, rsSurrPair, rsAstral].join('|') + ')';
  1943. /** Used to match apostrophes. */
  1944. var reApos = RegExp(rsApos, 'g');
  1945. /**
  1946. * Used to match [combining diacritical marks](https://en.wikipedia.org/wiki/Combining_Diacritical_Marks) and
  1947. * [combining diacritical marks for symbols](https://en.wikipedia.org/wiki/Combining_Diacritical_Marks_for_Symbols).
  1948. */
  1949. var reComboMark = RegExp(rsCombo, 'g');
  1950. /** Used to match [string symbols](https://mathiasbynens.be/notes/javascript-unicode). */
  1951. var reUnicode = RegExp(rsFitz + '(?=' + rsFitz + ')|' + rsSymbol + rsSeq, 'g');
  1952. /** Used to match complex or compound words. */
  1953. var reUnicodeWord = RegExp([
  1954. rsUpper + '?' + rsLower + '+' + rsOptContrLower + '(?=' + [rsBreak, rsUpper, '$'].join('|') + ')',
  1955. rsMiscUpper + '+' + rsOptContrUpper + '(?=' + [rsBreak, rsUpper + rsMiscLower, '$'].join('|') + ')',
  1956. rsUpper + '?' + rsMiscLower + '+' + rsOptContrLower,
  1957. rsUpper + '+' + rsOptContrUpper,
  1958. rsOrdUpper,
  1959. rsOrdLower,
  1960. rsDigits,
  1961. rsEmoji
  1962. ].join('|'), 'g');
  1963. /** 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/). */
  1964. var reHasUnicode = RegExp('[' + rsZWJ + rsAstralRange + rsComboRange + rsVarRange + ']');
  1965. /** Used to detect strings that need a more robust regexp to match words. */
  1966. 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 ]/;
  1967. /** Used to assign default `context` object properties. */
  1968. var contextProps = [
  1969. 'Array', 'Buffer', 'DataView', 'Date', 'Error', 'Float32Array', 'Float64Array',
  1970. 'Function', 'Int8Array', 'Int16Array', 'Int32Array', 'Map', 'Math', 'Object',
  1971. 'Promise', 'RegExp', 'Set', 'String', 'Symbol', 'TypeError', 'Uint8Array',
  1972. 'Uint8ClampedArray', 'Uint16Array', 'Uint32Array', 'WeakMap',
  1973. '_', 'clearTimeout', 'isFinite', 'parseInt', 'setTimeout'
  1974. ];
  1975. /** Used to make template sourceURLs easier to identify. */
  1976. var templateCounter = -1;
  1977. /** Used to identify `toStringTag` values of typed arrays. */
  1978. var typedArrayTags = {};
  1979. typedArrayTags[float32Tag] = typedArrayTags[float64Tag] =
  1980. typedArrayTags[int8Tag] = typedArrayTags[int16Tag] =
  1981. typedArrayTags[int32Tag] = typedArrayTags[uint8Tag] =
  1982. typedArrayTags[uint8ClampedTag] = typedArrayTags[uint16Tag] =
  1983. typedArrayTags[uint32Tag] = true;
  1984. typedArrayTags[argsTag] = typedArrayTags[arrayTag] =
  1985. typedArrayTags[arrayBufferTag] = typedArrayTags[boolTag] =
  1986. typedArrayTags[dataViewTag] = typedArrayTags[dateTag] =
  1987. typedArrayTags[errorTag] = typedArrayTags[funcTag] =
  1988. typedArrayTags[mapTag] = typedArrayTags[numberTag] =
  1989. typedArrayTags[objectTag] = typedArrayTags[regexpTag] =
  1990. typedArrayTags[setTag] = typedArrayTags[stringTag] =
  1991. typedArrayTags[weakMapTag] = false;
  1992. /** Used to identify `toStringTag` values supported by `_.clone`. */
  1993. var cloneableTags = {};
  1994. cloneableTags[argsTag] = cloneableTags[arrayTag] =
  1995. cloneableTags[arrayBufferTag] = cloneableTags[dataViewTag] =
  1996. cloneableTags[boolTag] = cloneableTags[dateTag] =
  1997. cloneableTags[float32Tag] = cloneableTags[float64Tag] =
  1998. cloneableTags[int8Tag] = cloneableTags[int16Tag] =
  1999. cloneableTags[int32Tag] = cloneableTags[mapTag] =
  2000. cloneableTags[numberTag] = cloneableTags[objectTag] =
  2001. cloneableTags[regexpTag] = cloneableTags[setTag] =
  2002. cloneableTags[stringTag] = cloneableTags[symbolTag] =
  2003. cloneableTags[uint8Tag] = cloneableTags[uint8ClampedTag] =
  2004. cloneableTags[uint16Tag] = cloneableTags[uint32Tag] = true;
  2005. cloneableTags[errorTag] = cloneableTags[funcTag] =
  2006. cloneableTags[weakMapTag] = false;
  2007. /** Used to map Latin Unicode letters to basic Latin letters. */
  2008. var deburredLetters = {
  2009. // Latin-1 Supplement block.
  2010. '\xc0': 'A', '\xc1': 'A', '\xc2': 'A', '\xc3': 'A', '\xc4': 'A', '\xc5': 'A',
  2011. '\xe0': 'a', '\xe1': 'a', '\xe2': 'a', '\xe3': 'a', '\xe4': 'a', '\xe5': 'a',
  2012. '\xc7': 'C', '\xe7': 'c',
  2013. '\xd0': 'D', '\xf0': 'd',
  2014. '\xc8': 'E', '\xc9': 'E', '\xca': 'E', '\xcb': 'E',
  2015. '\xe8': 'e', '\xe9': 'e', '\xea': 'e', '\xeb': 'e',
  2016. '\xcc': 'I', '\xcd': 'I', '\xce': 'I', '\xcf': 'I',
  2017. '\xec': 'i', '\xed': 'i', '\xee': 'i', '\xef': 'i',
  2018. '\xd1': 'N', '\xf1': 'n',
  2019. '\xd2': 'O', '\xd3': 'O', '\xd4': 'O', '\xd5': 'O', '\xd6': 'O', '\xd8': 'O',
  2020. '\xf2': 'o', '\xf3': 'o', '\xf4': 'o', '\xf5': 'o', '\xf6': 'o', '\xf8': 'o',
  2021. '\xd9': 'U', '\xda': 'U', '\xdb': 'U', '\xdc': 'U',
  2022. '\xf9': 'u', '\xfa': 'u', '\xfb': 'u', '\xfc': 'u',
  2023. '\xdd': 'Y', '\xfd': 'y', '\xff': 'y',
  2024. '\xc6': 'Ae', '\xe6': 'ae',
  2025. '\xde': 'Th', '\xfe': 'th',
  2026. '\xdf': 'ss',
  2027. // Latin Extended-A block.
  2028. '\u0100': 'A', '\u0102': 'A', '\u0104': 'A',
  2029. '\u0101': 'a', '\u0103': 'a', '\u0105': 'a',
  2030. '\u0106': 'C', '\u0108': 'C', '\u010a': 'C', '\u010c': 'C',
  2031. '\u0107': 'c', '\u0109': 'c', '\u010b': 'c', '\u010d': 'c',
  2032. '\u010e': 'D', '\u0110': 'D', '\u010f': 'd', '\u0111': 'd',
  2033. '\u0112': 'E', '\u0114': 'E', '\u0116': 'E', '\u0118': 'E', '\u011a': 'E',
  2034. '\u0113': 'e', '\u0115': 'e', '\u0117': 'e', '\u0119': 'e', '\u011b': 'e',
  2035. '\u011c': 'G', '\u011e': 'G', '\u0120': 'G', '\u0122': 'G',
  2036. '\u011d': 'g', '\u011f': 'g', '\u0121': 'g', '\u0123': 'g',
  2037. '\u0124': 'H', '\u0126': 'H', '\u0125': 'h', '\u0127': 'h',
  2038. '\u0128': 'I', '\u012a': 'I', '\u012c': 'I', '\u012e': 'I', '\u0130': 'I',
  2039. '\u0129': 'i', '\u012b': 'i', '\u012d': 'i', '\u012f': 'i', '\u0131': 'i',
  2040. '\u0134': 'J', '\u0135': 'j',
  2041. '\u0136': 'K', '\u0137': 'k', '\u0138': 'k',
  2042. '\u0139': 'L', '\u013b': 'L', '\u013d': 'L', '\u013f': 'L', '\u0141': 'L',
  2043. '\u013a': 'l', '\u013c': 'l', '\u013e': 'l', '\u0140': 'l', '\u0142': 'l',
  2044. '\u0143': 'N', '\u0145': 'N', '\u0147': 'N', '\u014a': 'N',
  2045. '\u0144': 'n', '\u0146': 'n', '\u0148': 'n', '\u014b': 'n',
  2046. '\u014c': 'O', '\u014e': 'O', '\u0150': 'O',
  2047. '\u014d': 'o', '\u014f': 'o', '\u0151': 'o',
  2048. '\u0154': 'R', '\u0156': 'R', '\u0158': 'R',
  2049. '\u0155': 'r', '\u0157': 'r', '\u0159': 'r',
  2050. '\u015a': 'S', '\u015c': 'S', '\u015e': 'S', '\u0160': 'S',
  2051. '\u015b': 's', '\u015d': 's', '\u015f': 's', '\u0161': 's',
  2052. '\u0162': 'T', '\u0164': 'T', '\u0166': 'T',
  2053. '\u0163': 't', '\u0165': 't', '\u0167': 't',
  2054. '\u0168': 'U', '\u016a': 'U', '\u016c': 'U', '\u016e': 'U', '\u0170': 'U', '\u0172': 'U',
  2055. '\u0169': 'u', '\u016b': 'u', '\u016d': 'u', '\u016f': 'u', '\u0171': 'u', '\u0173': 'u',
  2056. '\u0174': 'W', '\u0175': 'w',
  2057. '\u0176': 'Y', '\u0177': 'y', '\u0178': 'Y',
  2058. '\u0179': 'Z', '\u017b': 'Z', '\u017d': 'Z',
  2059. '\u017a': 'z', '\u017c': 'z', '\u017e': 'z',
  2060. '\u0132': 'IJ', '\u0133': 'ij',
  2061. '\u0152': 'Oe', '\u0153': 'oe',
  2062. '\u0149': "'n", '\u017f': 's'
  2063. };
  2064. /** Used to map characters to HTML entities. */
  2065. var htmlEscapes = {
  2066. '&': '&amp;',
  2067. '<': '&lt;',
  2068. '>': '&gt;',
  2069. '"': '&quot;',
  2070. "'": '&#39;'
  2071. };
  2072. /** Used to map HTML entities to characters. */
  2073. var htmlUnescapes = {
  2074. '&amp;': '&',
  2075. '&lt;': '<',
  2076. '&gt;': '>',
  2077. '&quot;': '"',
  2078. '&#39;': "'"
  2079. };
  2080. /** Used to escape characters for inclusion in compiled string literals. */
  2081. var stringEscapes = {
  2082. '\\': '\\',
  2083. "'": "'",
  2084. '\n': 'n',
  2085. '\r': 'r',
  2086. '\u2028': 'u2028',
  2087. '\u2029': 'u2029'
  2088. };
  2089. /** Built-in method references without a dependency on `root`. */
  2090. var freeParseFloat = parseFloat,
  2091. freeParseInt = parseInt;
  2092. /** Detect free variable `global` from Node.js. */
  2093. var freeGlobal = typeof __webpack_require__.g == 'object' && __webpack_require__.g && __webpack_require__.g.Object === Object && __webpack_require__.g;
  2094. /** Detect free variable `self`. */
  2095. var freeSelf = typeof self == 'object' && self && self.Object === Object && self;
  2096. /** Used as a reference to the global object. */
  2097. var root = freeGlobal || freeSelf || Function('return this')();
  2098. /** Detect free variable `exports`. */
  2099. var freeExports = true && exports && !exports.nodeType && exports;
  2100. /** Detect free variable `module`. */
  2101. var freeModule = freeExports && "object" == 'object' && module && !module.nodeType && module;
  2102. /** Detect the popular CommonJS extension `module.exports`. */
  2103. var moduleExports = freeModule && freeModule.exports === freeExports;
  2104. /** Detect free variable `process` from Node.js. */
  2105. var freeProcess = moduleExports && freeGlobal.process;
  2106. /** Used to access faster Node.js helpers. */
  2107. var nodeUtil = (function() {
  2108. try {
  2109. // Use `util.types` for Node.js 10+.
  2110. var types = freeModule && freeModule.require && freeModule.require('util').types;
  2111. if (types) {
  2112. return types;
  2113. }
  2114. // Legacy `process.binding('util')` for Node.js < 10.
  2115. return freeProcess && freeProcess.binding && freeProcess.binding('util');
  2116. } catch (e) {}
  2117. }());
  2118. /* Node.js helper references. */
  2119. var nodeIsArrayBuffer = nodeUtil && nodeUtil.isArrayBuffer,
  2120. nodeIsDate = nodeUtil && nodeUtil.isDate,
  2121. nodeIsMap = nodeUtil && nodeUtil.isMap,
  2122. nodeIsRegExp = nodeUtil && nodeUtil.isRegExp,
  2123. nodeIsSet = nodeUtil && nodeUtil.isSet,
  2124. nodeIsTypedArray = nodeUtil && nodeUtil.isTypedArray;
  2125. /*--------------------------------------------------------------------------*/
  2126. /**
  2127. * A faster alternative to `Function#apply`, this function invokes `func`
  2128. * with the `this` binding of `thisArg` and the arguments of `args`.
  2129. *
  2130. * @private
  2131. * @param {Function} func The function to invoke.
  2132. * @param {*} thisArg The `this` binding of `func`.
  2133. * @param {Array} args The arguments to invoke `func` with.
  2134. * @returns {*} Returns the result of `func`.
  2135. */
  2136. function apply(func, thisArg, args) {
  2137. switch (args.length) {
  2138. case 0: return func.call(thisArg);
  2139. case 1: return func.call(thisArg, args[0]);
  2140. case 2: return func.call(thisArg, args[0], args[1]);
  2141. case 3: return func.call(thisArg, args[0], args[1], args[2]);
  2142. }
  2143. return func.apply(thisArg, args);
  2144. }
  2145. /**
  2146. * A specialized version of `baseAggregator` for arrays.
  2147. *
  2148. * @private
  2149. * @param {Array} [array] The array to iterate over.
  2150. * @param {Function} setter The function to set `accumulator` values.
  2151. * @param {Function} iteratee The iteratee to transform keys.
  2152. * @param {Object} accumulator The initial aggregated object.
  2153. * @returns {Function} Returns `accumulator`.
  2154. */
  2155. function arrayAggregator(array, setter, iteratee, accumulator) {
  2156. var index = -1,
  2157. length = array == null ? 0 : array.length;
  2158. while (++index < length) {
  2159. var value = array[index];
  2160. setter(accumulator, value, iteratee(value), array);
  2161. }
  2162. return accumulator;
  2163. }
  2164. /**
  2165. * A specialized version of `_.forEach` for arrays without support for
  2166. * iteratee shorthands.
  2167. *
  2168. * @private
  2169. * @param {Array} [array] The array to iterate over.
  2170. * @param {Function} iteratee The function invoked per iteration.
  2171. * @returns {Array} Returns `array`.
  2172. */
  2173. function arrayEach(array, iteratee) {
  2174. var index = -1,
  2175. length = array == null ? 0 : array.length;
  2176. while (++index < length) {
  2177. if (iteratee(array[index], index, array) === false) {
  2178. break;
  2179. }
  2180. }
  2181. return array;
  2182. }
  2183. /**
  2184. * A specialized version of `_.forEachRight` for arrays without support for
  2185. * iteratee shorthands.
  2186. *
  2187. * @private
  2188. * @param {Array} [array] The array to iterate over.
  2189. * @param {Function} iteratee The function invoked per iteration.
  2190. * @returns {Array} Returns `array`.
  2191. */
  2192. function arrayEachRight(array, iteratee) {
  2193. var length = array == null ? 0 : array.length;
  2194. while (length--) {
  2195. if (iteratee(array[length], length, array) === false) {
  2196. break;
  2197. }
  2198. }
  2199. return array;
  2200. }
  2201. /**
  2202. * A specialized version of `_.every` for arrays without support for
  2203. * iteratee shorthands.
  2204. *
  2205. * @private
  2206. * @param {Array} [array] The array to iterate over.
  2207. * @param {Function} predicate The function invoked per iteration.
  2208. * @returns {boolean} Returns `true` if all elements pass the predicate check,
  2209. * else `false`.
  2210. */
  2211. function arrayEvery(array, predicate) {
  2212. var index = -1,
  2213. length = array == null ? 0 : array.length;
  2214. while (++index < length) {
  2215. if (!predicate(array[index], index, array)) {
  2216. return false;
  2217. }
  2218. }
  2219. return true;
  2220. }
  2221. /**
  2222. * A specialized version of `_.filter` for arrays without support for
  2223. * iteratee shorthands.
  2224. *
  2225. * @private
  2226. * @param {Array} [array] The array to iterate over.
  2227. * @param {Function} predicate The function invoked per iteration.
  2228. * @returns {Array} Returns the new filtered array.
  2229. */
  2230. function arrayFilter(array, predicate) {
  2231. var index = -1,
  2232. length = array == null ? 0 : array.length,
  2233. resIndex = 0,
  2234. result = [];
  2235. while (++index < length) {
  2236. var value = array[index];
  2237. if (predicate(value, index, array)) {
  2238. result[resIndex++] = value;
  2239. }
  2240. }
  2241. return result;
  2242. }
  2243. /**
  2244. * A specialized version of `_.includes` for arrays without support for
  2245. * specifying an index to search from.
  2246. *
  2247. * @private
  2248. * @param {Array} [array] The array to inspect.
  2249. * @param {*} target The value to search for.
  2250. * @returns {boolean} Returns `true` if `target` is found, else `false`.
  2251. */
  2252. function arrayIncludes(array, value) {
  2253. var length = array == null ? 0 : array.length;
  2254. return !!length && baseIndexOf(array, value, 0) > -1;
  2255. }
  2256. /**
  2257. * This function is like `arrayIncludes` except that it accepts a comparator.
  2258. *
  2259. * @private
  2260. * @param {Array} [array] The array to inspect.
  2261. * @param {*} target The value to search for.
  2262. * @param {Function} comparator The comparator invoked per element.
  2263. * @returns {boolean} Returns `true` if `target` is found, else `false`.
  2264. */
  2265. function arrayIncludesWith(array, value, comparator) {
  2266. var index = -1,
  2267. length = array == null ? 0 : array.length;
  2268. while (++index < length) {
  2269. if (comparator(value, array[index])) {
  2270. return true;
  2271. }
  2272. }
  2273. return false;
  2274. }
  2275. /**
  2276. * A specialized version of `_.map` for arrays without support for iteratee
  2277. * shorthands.
  2278. *
  2279. * @private
  2280. * @param {Array} [array] The array to iterate over.
  2281. * @param {Function} iteratee The function invoked per iteration.
  2282. * @returns {Array} Returns the new mapped array.
  2283. */
  2284. function arrayMap(array, iteratee) {
  2285. var index = -1,
  2286. length = array == null ? 0 : array.length,
  2287. result = Array(length);
  2288. while (++index < length) {
  2289. result[index] = iteratee(array[index], index, array);
  2290. }
  2291. return result;
  2292. }
  2293. /**
  2294. * Appends the elements of `values` to `array`.
  2295. *
  2296. * @private
  2297. * @param {Array} array The array to modify.
  2298. * @param {Array} values The values to append.
  2299. * @returns {Array} Returns `array`.
  2300. */
  2301. function arrayPush(array, values) {
  2302. var index = -1,
  2303. length = values.length,
  2304. offset = array.length;
  2305. while (++index < length) {
  2306. array[offset + index] = values[index];
  2307. }
  2308. return array;
  2309. }
  2310. /**
  2311. * A specialized version of `_.reduce` for arrays without support for
  2312. * iteratee shorthands.
  2313. *
  2314. * @private
  2315. * @param {Array} [array] The array to iterate over.
  2316. * @param {Function} iteratee The function invoked per iteration.
  2317. * @param {*} [accumulator] The initial value.
  2318. * @param {boolean} [initAccum] Specify using the first element of `array` as
  2319. * the initial value.
  2320. * @returns {*} Returns the accumulated value.
  2321. */
  2322. function arrayReduce(array, iteratee, accumulator, initAccum) {
  2323. var index = -1,
  2324. length = array == null ? 0 : array.length;
  2325. if (initAccum && length) {
  2326. accumulator = array[++index];
  2327. }
  2328. while (++index < length) {
  2329. accumulator = iteratee(accumulator, array[index], index, array);
  2330. }
  2331. return accumulator;
  2332. }
  2333. /**
  2334. * A specialized version of `_.reduceRight` for arrays without support for
  2335. * iteratee shorthands.
  2336. *
  2337. * @private
  2338. * @param {Array} [array] The array to iterate over.
  2339. * @param {Function} iteratee The function invoked per iteration.
  2340. * @param {*} [accumulator] The initial value.
  2341. * @param {boolean} [initAccum] Specify using the last element of `array` as
  2342. * the initial value.
  2343. * @returns {*} Returns the accumulated value.
  2344. */
  2345. function arrayReduceRight(array, iteratee, accumulator, initAccum) {
  2346. var length = array == null ? 0 : array.length;
  2347. if (initAccum && length) {
  2348. accumulator = array[--length];
  2349. }
  2350. while (length--) {
  2351. accumulator = iteratee(accumulator, array[length], length, array);
  2352. }
  2353. return accumulator;
  2354. }
  2355. /**
  2356. * A specialized version of `_.some` for arrays without support for iteratee
  2357. * shorthands.
  2358. *
  2359. * @private
  2360. * @param {Array} [array] The array to iterate over.
  2361. * @param {Function} predicate The function invoked per iteration.
  2362. * @returns {boolean} Returns `true` if any element passes the predicate check,
  2363. * else `false`.
  2364. */
  2365. function arraySome(array, predicate) {
  2366. var index = -1,
  2367. length = array == null ? 0 : array.length;
  2368. while (++index < length) {
  2369. if (predicate(array[index], index, array)) {
  2370. return true;
  2371. }
  2372. }
  2373. return false;
  2374. }
  2375. /**
  2376. * Gets the size of an ASCII `string`.
  2377. *
  2378. * @private
  2379. * @param {string} string The string inspect.
  2380. * @returns {number} Returns the string size.
  2381. */
  2382. var asciiSize = baseProperty('length');
  2383. /**
  2384. * Converts an ASCII `string` to an array.
  2385. *
  2386. * @private
  2387. * @param {string} string The string to convert.
  2388. * @returns {Array} Returns the converted array.
  2389. */
  2390. function asciiToArray(string) {
  2391. return string.split('');
  2392. }
  2393. /**
  2394. * Splits an ASCII `string` into an array of its words.
  2395. *
  2396. * @private
  2397. * @param {string} The string to inspect.
  2398. * @returns {Array} Returns the words of `string`.
  2399. */
  2400. function asciiWords(string) {
  2401. return string.match(reAsciiWord) || [];
  2402. }
  2403. /**
  2404. * The base implementation of methods like `_.findKey` and `_.findLastKey`,
  2405. * without support for iteratee shorthands, which iterates over `collection`
  2406. * using `eachFunc`.
  2407. *
  2408. * @private
  2409. * @param {Array|Object} collection The collection to inspect.
  2410. * @param {Function} predicate The function invoked per iteration.
  2411. * @param {Function} eachFunc The function to iterate over `collection`.
  2412. * @returns {*} Returns the found element or its key, else `undefined`.
  2413. */
  2414. function baseFindKey(collection, predicate, eachFunc) {
  2415. var result;
  2416. eachFunc(collection, function(value, key, collection) {
  2417. if (predicate(value, key, collection)) {
  2418. result = key;
  2419. return false;
  2420. }
  2421. });
  2422. return result;
  2423. }
  2424. /**
  2425. * The base implementation of `_.findIndex` and `_.findLastIndex` without
  2426. * support for iteratee shorthands.
  2427. *
  2428. * @private
  2429. * @param {Array} array The array to inspect.
  2430. * @param {Function} predicate The function invoked per iteration.
  2431. * @param {number} fromIndex The index to search from.
  2432. * @param {boolean} [fromRight] Specify iterating from right to left.
  2433. * @returns {number} Returns the index of the matched value, else `-1`.
  2434. */
  2435. function baseFindIndex(array, predicate, fromIndex, fromRight) {
  2436. var length = array.length,
  2437. index = fromIndex + (fromRight ? 1 : -1);
  2438. while ((fromRight ? index-- : ++index < length)) {
  2439. if (predicate(array[index], index, array)) {
  2440. return index;
  2441. }
  2442. }
  2443. return -1;
  2444. }
  2445. /**
  2446. * The base implementation of `_.indexOf` without `fromIndex` bounds checks.
  2447. *
  2448. * @private
  2449. * @param {Array} array The array to inspect.
  2450. * @param {*} value The value to search for.
  2451. * @param {number} fromIndex The index to search from.
  2452. * @returns {number} Returns the index of the matched value, else `-1`.
  2453. */
  2454. function baseIndexOf(array, value, fromIndex) {
  2455. return value === value
  2456. ? strictIndexOf(array, value, fromIndex)
  2457. : baseFindIndex(array, baseIsNaN, fromIndex);
  2458. }
  2459. /**
  2460. * This function is like `baseIndexOf` except that it accepts a comparator.
  2461. *
  2462. * @private
  2463. * @param {Array} array The array to inspect.
  2464. * @param {*} value The value to search for.
  2465. * @param {number} fromIndex The index to search from.
  2466. * @param {Function} comparator The comparator invoked per element.
  2467. * @returns {number} Returns the index of the matched value, else `-1`.
  2468. */
  2469. function baseIndexOfWith(array, value, fromIndex, comparator) {
  2470. var index = fromIndex - 1,
  2471. length = array.length;
  2472. while (++index < length) {
  2473. if (comparator(array[index], value)) {
  2474. return index;
  2475. }
  2476. }
  2477. return -1;
  2478. }
  2479. /**
  2480. * The base implementation of `_.isNaN` without support for number objects.
  2481. *
  2482. * @private
  2483. * @param {*} value The value to check.
  2484. * @returns {boolean} Returns `true` if `value` is `NaN`, else `false`.
  2485. */
  2486. function baseIsNaN(value) {
  2487. return value !== value;
  2488. }
  2489. /**
  2490. * The base implementation of `_.mean` and `_.meanBy` without support for
  2491. * iteratee shorthands.
  2492. *
  2493. * @private
  2494. * @param {Array} array The array to iterate over.
  2495. * @param {Function} iteratee The function invoked per iteration.
  2496. * @returns {number} Returns the mean.
  2497. */
  2498. function baseMean(array, iteratee) {
  2499. var length = array == null ? 0 : array.length;
  2500. return length ? (baseSum(array, iteratee) / length) : NAN;
  2501. }
  2502. /**
  2503. * The base implementation of `_.property` without support for deep paths.
  2504. *
  2505. * @private
  2506. * @param {string} key The key of the property to get.
  2507. * @returns {Function} Returns the new accessor function.
  2508. */
  2509. function baseProperty(key) {
  2510. return function(object) {
  2511. return object == null ? undefined : object[key];
  2512. };
  2513. }
  2514. /**
  2515. * The base implementation of `_.propertyOf` without support for deep paths.
  2516. *
  2517. * @private
  2518. * @param {Object} object The object to query.
  2519. * @returns {Function} Returns the new accessor function.
  2520. */
  2521. function basePropertyOf(object) {
  2522. return function(key) {
  2523. return object == null ? undefined : object[key];
  2524. };
  2525. }
  2526. /**
  2527. * The base implementation of `_.reduce` and `_.reduceRight`, without support
  2528. * for iteratee shorthands, which iterates over `collection` using `eachFunc`.
  2529. *
  2530. * @private
  2531. * @param {Array|Object} collection The collection to iterate over.
  2532. * @param {Function} iteratee The function invoked per iteration.
  2533. * @param {*} accumulator The initial value.
  2534. * @param {boolean} initAccum Specify using the first or last element of
  2535. * `collection` as the initial value.
  2536. * @param {Function} eachFunc The function to iterate over `collection`.
  2537. * @returns {*} Returns the accumulated value.
  2538. */
  2539. function baseReduce(collection, iteratee, accumulator, initAccum, eachFunc) {
  2540. eachFunc(collection, function(value, index, collection) {
  2541. accumulator = initAccum
  2542. ? (initAccum = false, value)
  2543. : iteratee(accumulator, value, index, collection);
  2544. });
  2545. return accumulator;
  2546. }
  2547. /**
  2548. * The base implementation of `_.sortBy` which uses `comparer` to define the
  2549. * sort order of `array` and replaces criteria objects with their corresponding
  2550. * values.
  2551. *
  2552. * @private
  2553. * @param {Array} array The array to sort.
  2554. * @param {Function} comparer The function to define sort order.
  2555. * @returns {Array} Returns `array`.
  2556. */
  2557. function baseSortBy(array, comparer) {
  2558. var length = array.length;
  2559. array.sort(comparer);
  2560. while (length--) {
  2561. array[length] = array[length].value;
  2562. }
  2563. return array;
  2564. }
  2565. /**
  2566. * The base implementation of `_.sum` and `_.sumBy` without support for
  2567. * iteratee shorthands.
  2568. *
  2569. * @private
  2570. * @param {Array} array The array to iterate over.
  2571. * @param {Function} iteratee The function invoked per iteration.
  2572. * @returns {number} Returns the sum.
  2573. */
  2574. function baseSum(array, iteratee) {
  2575. var result,
  2576. index = -1,
  2577. length = array.length;
  2578. while (++index < length) {
  2579. var current = iteratee(array[index]);
  2580. if (current !== undefined) {
  2581. result = result === undefined ? current : (result + current);
  2582. }
  2583. }
  2584. return result;
  2585. }
  2586. /**
  2587. * The base implementation of `_.times` without support for iteratee shorthands
  2588. * or max array length checks.
  2589. *
  2590. * @private
  2591. * @param {number} n The number of times to invoke `iteratee`.
  2592. * @param {Function} iteratee The function invoked per iteration.
  2593. * @returns {Array} Returns the array of results.
  2594. */
  2595. function baseTimes(n, iteratee) {
  2596. var index = -1,
  2597. result = Array(n);
  2598. while (++index < n) {
  2599. result[index] = iteratee(index);
  2600. }
  2601. return result;
  2602. }
  2603. /**
  2604. * The base implementation of `_.toPairs` and `_.toPairsIn` which creates an array
  2605. * of key-value pairs for `object` corresponding to the property names of `props`.
  2606. *
  2607. * @private
  2608. * @param {Object} object The object to query.
  2609. * @param {Array} props The property names to get values for.
  2610. * @returns {Object} Returns the key-value pairs.
  2611. */
  2612. function baseToPairs(object, props) {
  2613. return arrayMap(props, function(key) {
  2614. return [key, object[key]];
  2615. });
  2616. }
  2617. /**
  2618. * The base implementation of `_.trim`.
  2619. *
  2620. * @private
  2621. * @param {string} string The string to trim.
  2622. * @returns {string} Returns the trimmed string.
  2623. */
  2624. function baseTrim(string) {
  2625. return string
  2626. ? string.slice(0, trimmedEndIndex(string) + 1).replace(reTrimStart, '')
  2627. : string;
  2628. }
  2629. /**
  2630. * The base implementation of `_.unary` without support for storing metadata.
  2631. *
  2632. * @private
  2633. * @param {Function} func The function to cap arguments for.
  2634. * @returns {Function} Returns the new capped function.
  2635. */
  2636. function baseUnary(func) {
  2637. return function(value) {
  2638. return func(value);
  2639. };
  2640. }
  2641. /**
  2642. * The base implementation of `_.values` and `_.valuesIn` which creates an
  2643. * array of `object` property values corresponding to the property names
  2644. * of `props`.
  2645. *
  2646. * @private
  2647. * @param {Object} object The object to query.
  2648. * @param {Array} props The property names to get values for.
  2649. * @returns {Object} Returns the array of property values.
  2650. */
  2651. function baseValues(object, props) {
  2652. return arrayMap(props, function(key) {
  2653. return object[key];
  2654. });
  2655. }
  2656. /**
  2657. * Checks if a `cache` value for `key` exists.
  2658. *
  2659. * @private
  2660. * @param {Object} cache The cache to query.
  2661. * @param {string} key The key of the entry to check.
  2662. * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
  2663. */
  2664. function cacheHas(cache, key) {
  2665. return cache.has(key);
  2666. }
  2667. /**
  2668. * Used by `_.trim` and `_.trimStart` to get the index of the first string symbol
  2669. * that is not found in the character symbols.
  2670. *
  2671. * @private
  2672. * @param {Array} strSymbols The string symbols to inspect.
  2673. * @param {Array} chrSymbols The character symbols to find.
  2674. * @returns {number} Returns the index of the first unmatched string symbol.
  2675. */
  2676. function charsStartIndex(strSymbols, chrSymbols) {
  2677. var index = -1,
  2678. length = strSymbols.length;
  2679. while (++index < length && baseIndexOf(chrSymbols, strSymbols[index], 0) > -1) {}
  2680. return index;
  2681. }
  2682. /**
  2683. * Used by `_.trim` and `_.trimEnd` to get the index of the last string symbol
  2684. * that is not found in the character symbols.
  2685. *
  2686. * @private
  2687. * @param {Array} strSymbols The string symbols to inspect.
  2688. * @param {Array} chrSymbols The character symbols to find.
  2689. * @returns {number} Returns the index of the last unmatched string symbol.
  2690. */
  2691. function charsEndIndex(strSymbols, chrSymbols) {
  2692. var index = strSymbols.length;
  2693. while (index-- && baseIndexOf(chrSymbols, strSymbols[index], 0) > -1) {}
  2694. return index;
  2695. }
  2696. /**
  2697. * Gets the number of `placeholder` occurrences in `array`.
  2698. *
  2699. * @private
  2700. * @param {Array} array The array to inspect.
  2701. * @param {*} placeholder The placeholder to search for.
  2702. * @returns {number} Returns the placeholder count.
  2703. */
  2704. function countHolders(array, placeholder) {
  2705. var length = array.length,
  2706. result = 0;
  2707. while (length--) {
  2708. if (array[length] === placeholder) {
  2709. ++result;
  2710. }
  2711. }
  2712. return result;
  2713. }
  2714. /**
  2715. * Used by `_.deburr` to convert Latin-1 Supplement and Latin Extended-A
  2716. * letters to basic Latin letters.
  2717. *
  2718. * @private
  2719. * @param {string} letter The matched letter to deburr.
  2720. * @returns {string} Returns the deburred letter.
  2721. */
  2722. var deburrLetter = basePropertyOf(deburredLetters);
  2723. /**
  2724. * Used by `_.escape` to convert characters to HTML entities.
  2725. *
  2726. * @private
  2727. * @param {string} chr The matched character to escape.
  2728. * @returns {string} Returns the escaped character.
  2729. */
  2730. var escapeHtmlChar = basePropertyOf(htmlEscapes);
  2731. /**
  2732. * Used by `_.template` to escape characters for inclusion in compiled string literals.
  2733. *
  2734. * @private
  2735. * @param {string} chr The matched character to escape.
  2736. * @returns {string} Returns the escaped character.
  2737. */
  2738. function escapeStringChar(chr) {
  2739. return '\\' + stringEscapes[chr];
  2740. }
  2741. /**
  2742. * Gets the value at `key` of `object`.
  2743. *
  2744. * @private
  2745. * @param {Object} [object] The object to query.
  2746. * @param {string} key The key of the property to get.
  2747. * @returns {*} Returns the property value.
  2748. */
  2749. function getValue(object, key) {
  2750. return object == null ? undefined : object[key];
  2751. }
  2752. /**
  2753. * Checks if `string` contains Unicode symbols.
  2754. *
  2755. * @private
  2756. * @param {string} string The string to inspect.
  2757. * @returns {boolean} Returns `true` if a symbol is found, else `false`.
  2758. */
  2759. function hasUnicode(string) {
  2760. return reHasUnicode.test(string);
  2761. }
  2762. /**
  2763. * Checks if `string` contains a word composed of Unicode symbols.
  2764. *
  2765. * @private
  2766. * @param {string} string The string to inspect.
  2767. * @returns {boolean} Returns `true` if a word is found, else `false`.
  2768. */
  2769. function hasUnicodeWord(string) {
  2770. return reHasUnicodeWord.test(string);
  2771. }
  2772. /**
  2773. * Converts `iterator` to an array.
  2774. *
  2775. * @private
  2776. * @param {Object} iterator The iterator to convert.
  2777. * @returns {Array} Returns the converted array.
  2778. */
  2779. function iteratorToArray(iterator) {
  2780. var data,
  2781. result = [];
  2782. while (!(data = iterator.next()).done) {
  2783. result.push(data.value);
  2784. }
  2785. return result;
  2786. }
  2787. /**
  2788. * Converts `map` to its key-value pairs.
  2789. *
  2790. * @private
  2791. * @param {Object} map The map to convert.
  2792. * @returns {Array} Returns the key-value pairs.
  2793. */
  2794. function mapToArray(map) {
  2795. var index = -1,
  2796. result = Array(map.size);
  2797. map.forEach(function(value, key) {
  2798. result[++index] = [key, value];
  2799. });
  2800. return result;
  2801. }
  2802. /**
  2803. * Creates a unary function that invokes `func` with its argument transformed.
  2804. *
  2805. * @private
  2806. * @param {Function} func The function to wrap.
  2807. * @param {Function} transform The argument transform.
  2808. * @returns {Function} Returns the new function.
  2809. */
  2810. function overArg(func, transform) {
  2811. return function(arg) {
  2812. return func(transform(arg));
  2813. };
  2814. }
  2815. /**
  2816. * Replaces all `placeholder` elements in `array` with an internal placeholder
  2817. * and returns an array of their indexes.
  2818. *
  2819. * @private
  2820. * @param {Array} array The array to modify.
  2821. * @param {*} placeholder The placeholder to replace.
  2822. * @returns {Array} Returns the new array of placeholder indexes.
  2823. */
  2824. function replaceHolders(array, placeholder) {
  2825. var index = -1,
  2826. length = array.length,
  2827. resIndex = 0,
  2828. result = [];
  2829. while (++index < length) {
  2830. var value = array[index];
  2831. if (value === placeholder || value === PLACEHOLDER) {
  2832. array[index] = PLACEHOLDER;
  2833. result[resIndex++] = index;
  2834. }
  2835. }
  2836. return result;
  2837. }
  2838. /**
  2839. * Converts `set` to an array of its values.
  2840. *
  2841. * @private
  2842. * @param {Object} set The set to convert.
  2843. * @returns {Array} Returns the values.
  2844. */
  2845. function setToArray(set) {
  2846. var index = -1,
  2847. result = Array(set.size);
  2848. set.forEach(function(value) {
  2849. result[++index] = value;
  2850. });
  2851. return result;
  2852. }
  2853. /**
  2854. * Converts `set` to its value-value pairs.
  2855. *
  2856. * @private
  2857. * @param {Object} set The set to convert.
  2858. * @returns {Array} Returns the value-value pairs.
  2859. */
  2860. function setToPairs(set) {
  2861. var index = -1,
  2862. result = Array(set.size);
  2863. set.forEach(function(value) {
  2864. result[++index] = [value, value];
  2865. });
  2866. return result;
  2867. }
  2868. /**
  2869. * A specialized version of `_.indexOf` which performs strict equality
  2870. * comparisons of values, i.e. `===`.
  2871. *
  2872. * @private
  2873. * @param {Array} array The array to inspect.
  2874. * @param {*} value The value to search for.
  2875. * @param {number} fromIndex The index to search from.
  2876. * @returns {number} Returns the index of the matched value, else `-1`.
  2877. */
  2878. function strictIndexOf(array, value, fromIndex) {
  2879. var index = fromIndex - 1,
  2880. length = array.length;
  2881. while (++index < length) {
  2882. if (array[index] === value) {
  2883. return index;
  2884. }
  2885. }
  2886. return -1;
  2887. }
  2888. /**
  2889. * A specialized version of `_.lastIndexOf` which performs strict equality
  2890. * comparisons of values, i.e. `===`.
  2891. *
  2892. * @private
  2893. * @param {Array} array The array to inspect.
  2894. * @param {*} value The value to search for.
  2895. * @param {number} fromIndex The index to search from.
  2896. * @returns {number} Returns the index of the matched value, else `-1`.
  2897. */
  2898. function strictLastIndexOf(array, value, fromIndex) {
  2899. var index = fromIndex + 1;
  2900. while (index--) {
  2901. if (array[index] === value) {
  2902. return index;
  2903. }
  2904. }
  2905. return index;
  2906. }
  2907. /**
  2908. * Gets the number of symbols in `string`.
  2909. *
  2910. * @private
  2911. * @param {string} string The string to inspect.
  2912. * @returns {number} Returns the string size.
  2913. */
  2914. function stringSize(string) {
  2915. return hasUnicode(string)
  2916. ? unicodeSize(string)
  2917. : asciiSize(string);
  2918. }
  2919. /**
  2920. * Converts `string` to an array.
  2921. *
  2922. * @private
  2923. * @param {string} string The string to convert.
  2924. * @returns {Array} Returns the converted array.
  2925. */
  2926. function stringToArray(string) {
  2927. return hasUnicode(string)
  2928. ? unicodeToArray(string)
  2929. : asciiToArray(string);
  2930. }
  2931. /**
  2932. * Used by `_.trim` and `_.trimEnd` to get the index of the last non-whitespace
  2933. * character of `string`.
  2934. *
  2935. * @private
  2936. * @param {string} string The string to inspect.
  2937. * @returns {number} Returns the index of the last non-whitespace character.
  2938. */
  2939. function trimmedEndIndex(string) {
  2940. var index = string.length;
  2941. while (index-- && reWhitespace.test(string.charAt(index))) {}
  2942. return index;
  2943. }
  2944. /**
  2945. * Used by `_.unescape` to convert HTML entities to characters.
  2946. *
  2947. * @private
  2948. * @param {string} chr The matched character to unescape.
  2949. * @returns {string} Returns the unescaped character.
  2950. */
  2951. var unescapeHtmlChar = basePropertyOf(htmlUnescapes);
  2952. /**
  2953. * Gets the size of a Unicode `string`.
  2954. *
  2955. * @private
  2956. * @param {string} string The string inspect.
  2957. * @returns {number} Returns the string size.
  2958. */
  2959. function unicodeSize(string) {
  2960. var result = reUnicode.lastIndex = 0;
  2961. while (reUnicode.test(string)) {
  2962. ++result;
  2963. }
  2964. return result;
  2965. }
  2966. /**
  2967. * Converts a Unicode `string` to an array.
  2968. *
  2969. * @private
  2970. * @param {string} string The string to convert.
  2971. * @returns {Array} Returns the converted array.
  2972. */
  2973. function unicodeToArray(string) {
  2974. return string.match(reUnicode) || [];
  2975. }
  2976. /**
  2977. * Splits a Unicode `string` into an array of its words.
  2978. *
  2979. * @private
  2980. * @param {string} The string to inspect.
  2981. * @returns {Array} Returns the words of `string`.
  2982. */
  2983. function unicodeWords(string) {
  2984. return string.match(reUnicodeWord) || [];
  2985. }
  2986. /*--------------------------------------------------------------------------*/
  2987. /**
  2988. * Create a new pristine `lodash` function using the `context` object.
  2989. *
  2990. * @static
  2991. * @memberOf _
  2992. * @since 1.1.0
  2993. * @category Util
  2994. * @param {Object} [context=root] The context object.
  2995. * @returns {Function} Returns a new `lodash` function.
  2996. * @example
  2997. *
  2998. * _.mixin({ 'foo': _.constant('foo') });
  2999. *
  3000. * var lodash = _.runInContext();
  3001. * lodash.mixin({ 'bar': lodash.constant('bar') });
  3002. *
  3003. * _.isFunction(_.foo);
  3004. * // => true
  3005. * _.isFunction(_.bar);
  3006. * // => false
  3007. *
  3008. * lodash.isFunction(lodash.foo);
  3009. * // => false
  3010. * lodash.isFunction(lodash.bar);
  3011. * // => true
  3012. *
  3013. * // Create a suped-up `defer` in Node.js.
  3014. * var defer = _.runInContext({ 'setTimeout': setImmediate }).defer;
  3015. */
  3016. var runInContext = (function runInContext(context) {
  3017. context = context == null ? root : _.defaults(root.Object(), context, _.pick(root, contextProps));
  3018. /** Built-in constructor references. */
  3019. var Array = context.Array,
  3020. Date = context.Date,
  3021. Error = context.Error,
  3022. Function = context.Function,
  3023. Math = context.Math,
  3024. Object = context.Object,
  3025. RegExp = context.RegExp,
  3026. String = context.String,
  3027. TypeError = context.TypeError;
  3028. /** Used for built-in method references. */
  3029. var arrayProto = Array.prototype,
  3030. funcProto = Function.prototype,
  3031. objectProto = Object.prototype;
  3032. /** Used to detect overreaching core-js shims. */
  3033. var coreJsData = context['__core-js_shared__'];
  3034. /** Used to resolve the decompiled source of functions. */
  3035. var funcToString = funcProto.toString;
  3036. /** Used to check objects for own properties. */
  3037. var hasOwnProperty = objectProto.hasOwnProperty;
  3038. /** Used to generate unique IDs. */
  3039. var idCounter = 0;
  3040. /** Used to detect methods masquerading as native. */
  3041. var maskSrcKey = (function() {
  3042. var uid = /[^.]+$/.exec(coreJsData && coreJsData.keys && coreJsData.keys.IE_PROTO || '');
  3043. return uid ? ('Symbol(src)_1.' + uid) : '';
  3044. }());
  3045. /**
  3046. * Used to resolve the
  3047. * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
  3048. * of values.
  3049. */
  3050. var nativeObjectToString = objectProto.toString;
  3051. /** Used to infer the `Object` constructor. */
  3052. var objectCtorString = funcToString.call(Object);
  3053. /** Used to restore the original `_` reference in `_.noConflict`. */
  3054. var oldDash = root._;
  3055. /** Used to detect if a method is native. */
  3056. var reIsNative = RegExp('^' +
  3057. funcToString.call(hasOwnProperty).replace(reRegExpChar, '\\$&')
  3058. .replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, '$1.*?') + '$'
  3059. );
  3060. /** Built-in value references. */
  3061. var Buffer = moduleExports ? context.Buffer : undefined,
  3062. Symbol = context.Symbol,
  3063. Uint8Array = context.Uint8Array,
  3064. allocUnsafe = Buffer ? Buffer.allocUnsafe : undefined,
  3065. getPrototype = overArg(Object.getPrototypeOf, Object),
  3066. objectCreate = Object.create,
  3067. propertyIsEnumerable = objectProto.propertyIsEnumerable,
  3068. splice = arrayProto.splice,
  3069. spreadableSymbol = Symbol ? Symbol.isConcatSpreadable : undefined,
  3070. symIterator = Symbol ? Symbol.iterator : undefined,
  3071. symToStringTag = Symbol ? Symbol.toStringTag : undefined;
  3072. var defineProperty = (function() {
  3073. try {
  3074. var func = getNative(Object, 'defineProperty');
  3075. func({}, '', {});
  3076. return func;
  3077. } catch (e) {}
  3078. }());
  3079. /** Mocked built-ins. */
  3080. var ctxClearTimeout = context.clearTimeout !== root.clearTimeout && context.clearTimeout,
  3081. ctxNow = Date && Date.now !== root.Date.now && Date.now,
  3082. ctxSetTimeout = context.setTimeout !== root.setTimeout && context.setTimeout;
  3083. /* Built-in method references for those with the same name as other `lodash` methods. */
  3084. var nativeCeil = Math.ceil,
  3085. nativeFloor = Math.floor,
  3086. nativeGetSymbols = Object.getOwnPropertySymbols,
  3087. nativeIsBuffer = Buffer ? Buffer.isBuffer : undefined,
  3088. nativeIsFinite = context.isFinite,
  3089. nativeJoin = arrayProto.join,
  3090. nativeKeys = overArg(Object.keys, Object),
  3091. nativeMax = Math.max,
  3092. nativeMin = Math.min,
  3093. nativeNow = Date.now,
  3094. nativeParseInt = context.parseInt,
  3095. nativeRandom = Math.random,
  3096. nativeReverse = arrayProto.reverse;
  3097. /* Built-in method references that are verified to be native. */
  3098. var DataView = getNative(context, 'DataView'),
  3099. Map = getNative(context, 'Map'),
  3100. Promise = getNative(context, 'Promise'),
  3101. Set = getNative(context, 'Set'),
  3102. WeakMap = getNative(context, 'WeakMap'),
  3103. nativeCreate = getNative(Object, 'create');
  3104. /** Used to store function metadata. */
  3105. var metaMap = WeakMap && new WeakMap;
  3106. /** Used to lookup unminified function names. */
  3107. var realNames = {};
  3108. /** Used to detect maps, sets, and weakmaps. */
  3109. var dataViewCtorString = toSource(DataView),
  3110. mapCtorString = toSource(Map),
  3111. promiseCtorString = toSource(Promise),
  3112. setCtorString = toSource(Set),
  3113. weakMapCtorString = toSource(WeakMap);
  3114. /** Used to convert symbols to primitives and strings. */
  3115. var symbolProto = Symbol ? Symbol.prototype : undefined,
  3116. symbolValueOf = symbolProto ? symbolProto.valueOf : undefined,
  3117. symbolToString = symbolProto ? symbolProto.toString : undefined;
  3118. /*------------------------------------------------------------------------*/
  3119. /**
  3120. * Creates a `lodash` object which wraps `value` to enable implicit method
  3121. * chain sequences. Methods that operate on and return arrays, collections,
  3122. * and functions can be chained together. Methods that retrieve a single value
  3123. * or may return a primitive value will automatically end the chain sequence
  3124. * and return the unwrapped value. Otherwise, the value must be unwrapped
  3125. * with `_#value`.
  3126. *
  3127. * Explicit chain sequences, which must be unwrapped with `_#value`, may be
  3128. * enabled using `_.chain`.
  3129. *
  3130. * The execution of chained methods is lazy, that is, it's deferred until
  3131. * `_#value` is implicitly or explicitly called.
  3132. *
  3133. * Lazy evaluation allows several methods to support shortcut fusion.
  3134. * Shortcut fusion is an optimization to merge iteratee calls; this avoids
  3135. * the creation of intermediate arrays and can greatly reduce the number of
  3136. * iteratee executions. Sections of a chain sequence qualify for shortcut
  3137. * fusion if the section is applied to an array and iteratees accept only
  3138. * one argument. The heuristic for whether a section qualifies for shortcut
  3139. * fusion is subject to change.
  3140. *
  3141. * Chaining is supported in custom builds as long as the `_#value` method is
  3142. * directly or indirectly included in the build.
  3143. *
  3144. * In addition to lodash methods, wrappers have `Array` and `String` methods.
  3145. *
  3146. * The wrapper `Array` methods are:
  3147. * `concat`, `join`, `pop`, `push`, `shift`, `sort`, `splice`, and `unshift`
  3148. *
  3149. * The wrapper `String` methods are:
  3150. * `replace` and `split`
  3151. *
  3152. * The wrapper methods that support shortcut fusion are:
  3153. * `at`, `compact`, `drop`, `dropRight`, `dropWhile`, `filter`, `find`,
  3154. * `findLast`, `head`, `initial`, `last`, `map`, `reject`, `reverse`, `slice`,
  3155. * `tail`, `take`, `takeRight`, `takeRightWhile`, `takeWhile`, and `toArray`
  3156. *
  3157. * The chainable wrapper methods are:
  3158. * `after`, `ary`, `assign`, `assignIn`, `assignInWith`, `assignWith`, `at`,
  3159. * `before`, `bind`, `bindAll`, `bindKey`, `castArray`, `chain`, `chunk`,
  3160. * `commit`, `compact`, `concat`, `conforms`, `constant`, `countBy`, `create`,
  3161. * `curry`, `debounce`, `defaults`, `defaultsDeep`, `defer`, `delay`,
  3162. * `difference`, `differenceBy`, `differenceWith`, `drop`, `dropRight`,
  3163. * `dropRightWhile`, `dropWhile`, `extend`, `extendWith`, `fill`, `filter`,
  3164. * `flatMap`, `flatMapDeep`, `flatMapDepth`, `flatten`, `flattenDeep`,
  3165. * `flattenDepth`, `flip`, `flow`, `flowRight`, `fromPairs`, `functions`,
  3166. * `functionsIn`, `groupBy`, `initial`, `intersection`, `intersectionBy`,
  3167. * `intersectionWith`, `invert`, `invertBy`, `invokeMap`, `iteratee`, `keyBy`,
  3168. * `keys`, `keysIn`, `map`, `mapKeys`, `mapValues`, `matches`, `matchesProperty`,
  3169. * `memoize`, `merge`, `mergeWith`, `method`, `methodOf`, `mixin`, `negate`,
  3170. * `nthArg`, `omit`, `omitBy`, `once`, `orderBy`, `over`, `overArgs`,
  3171. * `overEvery`, `overSome`, `partial`, `partialRight`, `partition`, `pick`,
  3172. * `pickBy`, `plant`, `property`, `propertyOf`, `pull`, `pullAll`, `pullAllBy`,
  3173. * `pullAllWith`, `pullAt`, `push`, `range`, `rangeRight`, `rearg`, `reject`,
  3174. * `remove`, `rest`, `reverse`, `sampleSize`, `set`, `setWith`, `shuffle`,
  3175. * `slice`, `sort`, `sortBy`, `splice`, `spread`, `tail`, `take`, `takeRight`,
  3176. * `takeRightWhile`, `takeWhile`, `tap`, `throttle`, `thru`, `toArray`,
  3177. * `toPairs`, `toPairsIn`, `toPath`, `toPlainObject`, `transform`, `unary`,
  3178. * `union`, `unionBy`, `unionWith`, `uniq`, `uniqBy`, `uniqWith`, `unset`,
  3179. * `unshift`, `unzip`, `unzipWith`, `update`, `updateWith`, `values`,
  3180. * `valuesIn`, `without`, `wrap`, `xor`, `xorBy`, `xorWith`, `zip`,
  3181. * `zipObject`, `zipObjectDeep`, and `zipWith`
  3182. *
  3183. * The wrapper methods that are **not** chainable by default are:
  3184. * `add`, `attempt`, `camelCase`, `capitalize`, `ceil`, `clamp`, `clone`,
  3185. * `cloneDeep`, `cloneDeepWith`, `cloneWith`, `conformsTo`, `deburr`,
  3186. * `defaultTo`, `divide`, `each`, `eachRight`, `endsWith`, `eq`, `escape`,
  3187. * `escapeRegExp`, `every`, `find`, `findIndex`, `findKey`, `findLast`,
  3188. * `findLastIndex`, `findLastKey`, `first`, `floor`, `forEach`, `forEachRight`,
  3189. * `forIn`, `forInRight`, `forOwn`, `forOwnRight`, `get`, `gt`, `gte`, `has`,
  3190. * `hasIn`, `head`, `identity`, `includes`, `indexOf`, `inRange`, `invoke`,
  3191. * `isArguments`, `isArray`, `isArrayBuffer`, `isArrayLike`, `isArrayLikeObject`,
  3192. * `isBoolean`, `isBuffer`, `isDate`, `isElement`, `isEmpty`, `isEqual`,
  3193. * `isEqualWith`, `isError`, `isFinite`, `isFunction`, `isInteger`, `isLength`,
  3194. * `isMap`, `isMatch`, `isMatchWith`, `isNaN`, `isNative`, `isNil`, `isNull`,
  3195. * `isNumber`, `isObject`, `isObjectLike`, `isPlainObject`, `isRegExp`,
  3196. * `isSafeInteger`, `isSet`, `isString`, `isUndefined`, `isTypedArray`,
  3197. * `isWeakMap`, `isWeakSet`, `join`, `kebabCase`, `last`, `lastIndexOf`,
  3198. * `lowerCase`, `lowerFirst`, `lt`, `lte`, `max`, `maxBy`, `mean`, `meanBy`,
  3199. * `min`, `minBy`, `multiply`, `noConflict`, `noop`, `now`, `nth`, `pad`,
  3200. * `padEnd`, `padStart`, `parseInt`, `pop`, `random`, `reduce`, `reduceRight`,
  3201. * `repeat`, `result`, `round`, `runInContext`, `sample`, `shift`, `size`,
  3202. * `snakeCase`, `some`, `sortedIndex`, `sortedIndexBy`, `sortedLastIndex`,
  3203. * `sortedLastIndexBy`, `startCase`, `startsWith`, `stubArray`, `stubFalse`,
  3204. * `stubObject`, `stubString`, `stubTrue`, `subtract`, `sum`, `sumBy`,
  3205. * `template`, `times`, `toFinite`, `toInteger`, `toJSON`, `toLength`,
  3206. * `toLower`, `toNumber`, `toSafeInteger`, `toString`, `toUpper`, `trim`,
  3207. * `trimEnd`, `trimStart`, `truncate`, `unescape`, `uniqueId`, `upperCase`,
  3208. * `upperFirst`, `value`, and `words`
  3209. *
  3210. * @name _
  3211. * @constructor
  3212. * @category Seq
  3213. * @param {*} value The value to wrap in a `lodash` instance.
  3214. * @returns {Object} Returns the new `lodash` wrapper instance.
  3215. * @example
  3216. *
  3217. * function square(n) {
  3218. * return n * n;
  3219. * }
  3220. *
  3221. * var wrapped = _([1, 2, 3]);
  3222. *
  3223. * // Returns an unwrapped value.
  3224. * wrapped.reduce(_.add);
  3225. * // => 6
  3226. *
  3227. * // Returns a wrapped value.
  3228. * var squares = wrapped.map(square);
  3229. *
  3230. * _.isArray(squares);
  3231. * // => false
  3232. *
  3233. * _.isArray(squares.value());
  3234. * // => true
  3235. */
  3236. function lodash(value) {
  3237. if (isObjectLike(value) && !isArray(value) && !(value instanceof LazyWrapper)) {
  3238. if (value instanceof LodashWrapper) {
  3239. return value;
  3240. }
  3241. if (hasOwnProperty.call(value, '__wrapped__')) {
  3242. return wrapperClone(value);
  3243. }
  3244. }
  3245. return new LodashWrapper(value);
  3246. }
  3247. /**
  3248. * The base implementation of `_.create` without support for assigning
  3249. * properties to the created object.
  3250. *
  3251. * @private
  3252. * @param {Object} proto The object to inherit from.
  3253. * @returns {Object} Returns the new object.
  3254. */
  3255. var baseCreate = (function() {
  3256. function object() {}
  3257. return function(proto) {
  3258. if (!isObject(proto)) {
  3259. return {};
  3260. }
  3261. if (objectCreate) {
  3262. return objectCreate(proto);
  3263. }
  3264. object.prototype = proto;
  3265. var result = new object;
  3266. object.prototype = undefined;
  3267. return result;
  3268. };
  3269. }());
  3270. /**
  3271. * The function whose prototype chain sequence wrappers inherit from.
  3272. *
  3273. * @private
  3274. */
  3275. function baseLodash() {
  3276. // No operation performed.
  3277. }
  3278. /**
  3279. * The base constructor for creating `lodash` wrapper objects.
  3280. *
  3281. * @private
  3282. * @param {*} value The value to wrap.
  3283. * @param {boolean} [chainAll] Enable explicit method chain sequences.
  3284. */
  3285. function LodashWrapper(value, chainAll) {
  3286. this.__wrapped__ = value;
  3287. this.__actions__ = [];
  3288. this.__chain__ = !!chainAll;
  3289. this.__index__ = 0;
  3290. this.__values__ = undefined;
  3291. }
  3292. /**
  3293. * By default, the template delimiters used by lodash are like those in
  3294. * embedded Ruby (ERB) as well as ES2015 template strings. Change the
  3295. * following template settings to use alternative delimiters.
  3296. *
  3297. * @static
  3298. * @memberOf _
  3299. * @type {Object}
  3300. */
  3301. lodash.templateSettings = {
  3302. /**
  3303. * Used to detect `data` property values to be HTML-escaped.
  3304. *
  3305. * @memberOf _.templateSettings
  3306. * @type {RegExp}
  3307. */
  3308. 'escape': reEscape,
  3309. /**
  3310. * Used to detect code to be evaluated.
  3311. *
  3312. * @memberOf _.templateSettings
  3313. * @type {RegExp}
  3314. */
  3315. 'evaluate': reEvaluate,
  3316. /**
  3317. * Used to detect `data` property values to inject.
  3318. *
  3319. * @memberOf _.templateSettings
  3320. * @type {RegExp}
  3321. */
  3322. 'interpolate': reInterpolate,
  3323. /**
  3324. * Used to reference the data object in the template text.
  3325. *
  3326. * @memberOf _.templateSettings
  3327. * @type {string}
  3328. */
  3329. 'variable': '',
  3330. /**
  3331. * Used to import variables into the compiled template.
  3332. *
  3333. * @memberOf _.templateSettings
  3334. * @type {Object}
  3335. */
  3336. 'imports': {
  3337. /**
  3338. * A reference to the `lodash` function.
  3339. *
  3340. * @memberOf _.templateSettings.imports
  3341. * @type {Function}
  3342. */
  3343. '_': lodash
  3344. }
  3345. };
  3346. // Ensure wrappers are instances of `baseLodash`.
  3347. lodash.prototype = baseLodash.prototype;
  3348. lodash.prototype.constructor = lodash;
  3349. LodashWrapper.prototype = baseCreate(baseLodash.prototype);
  3350. LodashWrapper.prototype.constructor = LodashWrapper;
  3351. /*------------------------------------------------------------------------*/
  3352. /**
  3353. * Creates a lazy wrapper object which wraps `value` to enable lazy evaluation.
  3354. *
  3355. * @private
  3356. * @constructor
  3357. * @param {*} value The value to wrap.
  3358. */
  3359. function LazyWrapper(value) {
  3360. this.__wrapped__ = value;
  3361. this.__actions__ = [];
  3362. this.__dir__ = 1;
  3363. this.__filtered__ = false;
  3364. this.__iteratees__ = [];
  3365. this.__takeCount__ = MAX_ARRAY_LENGTH;
  3366. this.__views__ = [];
  3367. }
  3368. /**
  3369. * Creates a clone of the lazy wrapper object.
  3370. *
  3371. * @private
  3372. * @name clone
  3373. * @memberOf LazyWrapper
  3374. * @returns {Object} Returns the cloned `LazyWrapper` object.
  3375. */
  3376. function lazyClone() {
  3377. var result = new LazyWrapper(this.__wrapped__);
  3378. result.__actions__ = copyArray(this.__actions__);
  3379. result.__dir__ = this.__dir__;
  3380. result.__filtered__ = this.__filtered__;
  3381. result.__iteratees__ = copyArray(this.__iteratees__);
  3382. result.__takeCount__ = this.__takeCount__;
  3383. result.__views__ = copyArray(this.__views__);
  3384. return result;
  3385. }
  3386. /**
  3387. * Reverses the direction of lazy iteration.
  3388. *
  3389. * @private
  3390. * @name reverse
  3391. * @memberOf LazyWrapper
  3392. * @returns {Object} Returns the new reversed `LazyWrapper` object.
  3393. */
  3394. function lazyReverse() {
  3395. if (this.__filtered__) {
  3396. var result = new LazyWrapper(this);
  3397. result.__dir__ = -1;
  3398. result.__filtered__ = true;
  3399. } else {
  3400. result = this.clone();
  3401. result.__dir__ *= -1;
  3402. }
  3403. return result;
  3404. }
  3405. /**
  3406. * Extracts the unwrapped value from its lazy wrapper.
  3407. *
  3408. * @private
  3409. * @name value
  3410. * @memberOf LazyWrapper
  3411. * @returns {*} Returns the unwrapped value.
  3412. */
  3413. function lazyValue() {
  3414. var array = this.__wrapped__.value(),
  3415. dir = this.__dir__,
  3416. isArr = isArray(array),
  3417. isRight = dir < 0,
  3418. arrLength = isArr ? array.length : 0,
  3419. view = getView(0, arrLength, this.__views__),
  3420. start = view.start,
  3421. end = view.end,
  3422. length = end - start,
  3423. index = isRight ? end : (start - 1),
  3424. iteratees = this.__iteratees__,
  3425. iterLength = iteratees.length,
  3426. resIndex = 0,
  3427. takeCount = nativeMin(length, this.__takeCount__);
  3428. if (!isArr || (!isRight && arrLength == length && takeCount == length)) {
  3429. return baseWrapperValue(array, this.__actions__);
  3430. }
  3431. var result = [];
  3432. outer:
  3433. while (length-- && resIndex < takeCount) {
  3434. index += dir;
  3435. var iterIndex = -1,
  3436. value = array[index];
  3437. while (++iterIndex < iterLength) {
  3438. var data = iteratees[iterIndex],
  3439. iteratee = data.iteratee,
  3440. type = data.type,
  3441. computed = iteratee(value);
  3442. if (type == LAZY_MAP_FLAG) {
  3443. value = computed;
  3444. } else if (!computed) {
  3445. if (type == LAZY_FILTER_FLAG) {
  3446. continue outer;
  3447. } else {
  3448. break outer;
  3449. }
  3450. }
  3451. }
  3452. result[resIndex++] = value;
  3453. }
  3454. return result;
  3455. }
  3456. // Ensure `LazyWrapper` is an instance of `baseLodash`.
  3457. LazyWrapper.prototype = baseCreate(baseLodash.prototype);
  3458. LazyWrapper.prototype.constructor = LazyWrapper;
  3459. /*------------------------------------------------------------------------*/
  3460. /**
  3461. * Creates a hash object.
  3462. *
  3463. * @private
  3464. * @constructor
  3465. * @param {Array} [entries] The key-value pairs to cache.
  3466. */
  3467. function Hash(entries) {
  3468. var index = -1,
  3469. length = entries == null ? 0 : entries.length;
  3470. this.clear();
  3471. while (++index < length) {
  3472. var entry = entries[index];
  3473. this.set(entry[0], entry[1]);
  3474. }
  3475. }
  3476. /**
  3477. * Removes all key-value entries from the hash.
  3478. *
  3479. * @private
  3480. * @name clear
  3481. * @memberOf Hash
  3482. */
  3483. function hashClear() {
  3484. this.__data__ = nativeCreate ? nativeCreate(null) : {};
  3485. this.size = 0;
  3486. }
  3487. /**
  3488. * Removes `key` and its value from the hash.
  3489. *
  3490. * @private
  3491. * @name delete
  3492. * @memberOf Hash
  3493. * @param {Object} hash The hash to modify.
  3494. * @param {string} key The key of the value to remove.
  3495. * @returns {boolean} Returns `true` if the entry was removed, else `false`.
  3496. */
  3497. function hashDelete(key) {
  3498. var result = this.has(key) && delete this.__data__[key];
  3499. this.size -= result ? 1 : 0;
  3500. return result;
  3501. }
  3502. /**
  3503. * Gets the hash value for `key`.
  3504. *
  3505. * @private
  3506. * @name get
  3507. * @memberOf Hash
  3508. * @param {string} key The key of the value to get.
  3509. * @returns {*} Returns the entry value.
  3510. */
  3511. function hashGet(key) {
  3512. var data = this.__data__;
  3513. if (nativeCreate) {
  3514. var result = data[key];
  3515. return result === HASH_UNDEFINED ? undefined : result;
  3516. }
  3517. return hasOwnProperty.call(data, key) ? data[key] : undefined;
  3518. }
  3519. /**
  3520. * Checks if a hash value for `key` exists.
  3521. *
  3522. * @private
  3523. * @name has
  3524. * @memberOf Hash
  3525. * @param {string} key The key of the entry to check.
  3526. * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
  3527. */
  3528. function hashHas(key) {
  3529. var data = this.__data__;
  3530. return nativeCreate ? (data[key] !== undefined) : hasOwnProperty.call(data, key);
  3531. }
  3532. /**
  3533. * Sets the hash `key` to `value`.
  3534. *
  3535. * @private
  3536. * @name set
  3537. * @memberOf Hash
  3538. * @param {string} key The key of the value to set.
  3539. * @param {*} value The value to set.
  3540. * @returns {Object} Returns the hash instance.
  3541. */
  3542. function hashSet(key, value) {
  3543. var data = this.__data__;
  3544. this.size += this.has(key) ? 0 : 1;
  3545. data[key] = (nativeCreate && value === undefined) ? HASH_UNDEFINED : value;
  3546. return this;
  3547. }
  3548. // Add methods to `Hash`.
  3549. Hash.prototype.clear = hashClear;
  3550. Hash.prototype['delete'] = hashDelete;
  3551. Hash.prototype.get = hashGet;
  3552. Hash.prototype.has = hashHas;
  3553. Hash.prototype.set = hashSet;
  3554. /*------------------------------------------------------------------------*/
  3555. /**
  3556. * Creates an list cache object.
  3557. *
  3558. * @private
  3559. * @constructor
  3560. * @param {Array} [entries] The key-value pairs to cache.
  3561. */
  3562. function ListCache(entries) {
  3563. var index = -1,
  3564. length = entries == null ? 0 : entries.length;
  3565. this.clear();
  3566. while (++index < length) {
  3567. var entry = entries[index];
  3568. this.set(entry[0], entry[1]);
  3569. }
  3570. }
  3571. /**
  3572. * Removes all key-value entries from the list cache.
  3573. *
  3574. * @private
  3575. * @name clear
  3576. * @memberOf ListCache
  3577. */
  3578. function listCacheClear() {
  3579. this.__data__ = [];
  3580. this.size = 0;
  3581. }
  3582. /**
  3583. * Removes `key` and its value from the list cache.
  3584. *
  3585. * @private
  3586. * @name delete
  3587. * @memberOf ListCache
  3588. * @param {string} key The key of the value to remove.
  3589. * @returns {boolean} Returns `true` if the entry was removed, else `false`.
  3590. */
  3591. function listCacheDelete(key) {
  3592. var data = this.__data__,
  3593. index = assocIndexOf(data, key);
  3594. if (index < 0) {
  3595. return false;
  3596. }
  3597. var lastIndex = data.length - 1;
  3598. if (index == lastIndex) {
  3599. data.pop();
  3600. } else {
  3601. splice.call(data, index, 1);
  3602. }
  3603. --this.size;
  3604. return true;
  3605. }
  3606. /**
  3607. * Gets the list cache value for `key`.
  3608. *
  3609. * @private
  3610. * @name get
  3611. * @memberOf ListCache
  3612. * @param {string} key The key of the value to get.
  3613. * @returns {*} Returns the entry value.
  3614. */
  3615. function listCacheGet(key) {
  3616. var data = this.__data__,
  3617. index = assocIndexOf(data, key);
  3618. return index < 0 ? undefined : data[index][1];
  3619. }
  3620. /**
  3621. * Checks if a list cache value for `key` exists.
  3622. *
  3623. * @private
  3624. * @name has
  3625. * @memberOf ListCache
  3626. * @param {string} key The key of the entry to check.
  3627. * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
  3628. */
  3629. function listCacheHas(key) {
  3630. return assocIndexOf(this.__data__, key) > -1;
  3631. }
  3632. /**
  3633. * Sets the list cache `key` to `value`.
  3634. *
  3635. * @private
  3636. * @name set
  3637. * @memberOf ListCache
  3638. * @param {string} key The key of the value to set.
  3639. * @param {*} value The value to set.
  3640. * @returns {Object} Returns the list cache instance.
  3641. */
  3642. function listCacheSet(key, value) {
  3643. var data = this.__data__,
  3644. index = assocIndexOf(data, key);
  3645. if (index < 0) {
  3646. ++this.size;
  3647. data.push([key, value]);
  3648. } else {
  3649. data[index][1] = value;
  3650. }
  3651. return this;
  3652. }
  3653. // Add methods to `ListCache`.
  3654. ListCache.prototype.clear = listCacheClear;
  3655. ListCache.prototype['delete'] = listCacheDelete;
  3656. ListCache.prototype.get = listCacheGet;
  3657. ListCache.prototype.has = listCacheHas;
  3658. ListCache.prototype.set = listCacheSet;
  3659. /*------------------------------------------------------------------------*/
  3660. /**
  3661. * Creates a map cache object to store key-value pairs.
  3662. *
  3663. * @private
  3664. * @constructor
  3665. * @param {Array} [entries] The key-value pairs to cache.
  3666. */
  3667. function MapCache(entries) {
  3668. var index = -1,
  3669. length = entries == null ? 0 : entries.length;
  3670. this.clear();
  3671. while (++index < length) {
  3672. var entry = entries[index];
  3673. this.set(entry[0], entry[1]);
  3674. }
  3675. }
  3676. /**
  3677. * Removes all key-value entries from the map.
  3678. *
  3679. * @private
  3680. * @name clear
  3681. * @memberOf MapCache
  3682. */
  3683. function mapCacheClear() {
  3684. this.size = 0;
  3685. this.__data__ = {
  3686. 'hash': new Hash,
  3687. 'map': new (Map || ListCache),
  3688. 'string': new Hash
  3689. };
  3690. }
  3691. /**
  3692. * Removes `key` and its value from the map.
  3693. *
  3694. * @private
  3695. * @name delete
  3696. * @memberOf MapCache
  3697. * @param {string} key The key of the value to remove.
  3698. * @returns {boolean} Returns `true` if the entry was removed, else `false`.
  3699. */
  3700. function mapCacheDelete(key) {
  3701. var result = getMapData(this, key)['delete'](key);
  3702. this.size -= result ? 1 : 0;
  3703. return result;
  3704. }
  3705. /**
  3706. * Gets the map value for `key`.
  3707. *
  3708. * @private
  3709. * @name get
  3710. * @memberOf MapCache
  3711. * @param {string} key The key of the value to get.
  3712. * @returns {*} Returns the entry value.
  3713. */
  3714. function mapCacheGet(key) {
  3715. return getMapData(this, key).get(key);
  3716. }
  3717. /**
  3718. * Checks if a map value for `key` exists.
  3719. *
  3720. * @private
  3721. * @name has
  3722. * @memberOf MapCache
  3723. * @param {string} key The key of the entry to check.
  3724. * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
  3725. */
  3726. function mapCacheHas(key) {
  3727. return getMapData(this, key).has(key);
  3728. }
  3729. /**
  3730. * Sets the map `key` to `value`.
  3731. *
  3732. * @private
  3733. * @name set
  3734. * @memberOf MapCache
  3735. * @param {string} key The key of the value to set.
  3736. * @param {*} value The value to set.
  3737. * @returns {Object} Returns the map cache instance.
  3738. */
  3739. function mapCacheSet(key, value) {
  3740. var data = getMapData(this, key),
  3741. size = data.size;
  3742. data.set(key, value);
  3743. this.size += data.size == size ? 0 : 1;
  3744. return this;
  3745. }
  3746. // Add methods to `MapCache`.
  3747. MapCache.prototype.clear = mapCacheClear;
  3748. MapCache.prototype['delete'] = mapCacheDelete;
  3749. MapCache.prototype.get = mapCacheGet;
  3750. MapCache.prototype.has = mapCacheHas;
  3751. MapCache.prototype.set = mapCacheSet;
  3752. /*------------------------------------------------------------------------*/
  3753. /**
  3754. *
  3755. * Creates an array cache object to store unique values.
  3756. *
  3757. * @private
  3758. * @constructor
  3759. * @param {Array} [values] The values to cache.
  3760. */
  3761. function SetCache(values) {
  3762. var index = -1,
  3763. length = values == null ? 0 : values.length;
  3764. this.__data__ = new MapCache;
  3765. while (++index < length) {
  3766. this.add(values[index]);
  3767. }
  3768. }
  3769. /**
  3770. * Adds `value` to the array cache.
  3771. *
  3772. * @private
  3773. * @name add
  3774. * @memberOf SetCache
  3775. * @alias push
  3776. * @param {*} value The value to cache.
  3777. * @returns {Object} Returns the cache instance.
  3778. */
  3779. function setCacheAdd(value) {
  3780. this.__data__.set(value, HASH_UNDEFINED);
  3781. return this;
  3782. }
  3783. /**
  3784. * Checks if `value` is in the array cache.
  3785. *
  3786. * @private
  3787. * @name has
  3788. * @memberOf SetCache
  3789. * @param {*} value The value to search for.
  3790. * @returns {number} Returns `true` if `value` is found, else `false`.
  3791. */
  3792. function setCacheHas(value) {
  3793. return this.__data__.has(value);
  3794. }
  3795. // Add methods to `SetCache`.
  3796. SetCache.prototype.add = SetCache.prototype.push = setCacheAdd;
  3797. SetCache.prototype.has = setCacheHas;
  3798. /*------------------------------------------------------------------------*/
  3799. /**
  3800. * Creates a stack cache object to store key-value pairs.
  3801. *
  3802. * @private
  3803. * @constructor
  3804. * @param {Array} [entries] The key-value pairs to cache.
  3805. */
  3806. function Stack(entries) {
  3807. var data = this.__data__ = new ListCache(entries);
  3808. this.size = data.size;
  3809. }
  3810. /**
  3811. * Removes all key-value entries from the stack.
  3812. *
  3813. * @private
  3814. * @name clear
  3815. * @memberOf Stack
  3816. */
  3817. function stackClear() {
  3818. this.__data__ = new ListCache;
  3819. this.size = 0;
  3820. }
  3821. /**
  3822. * Removes `key` and its value from the stack.
  3823. *
  3824. * @private
  3825. * @name delete
  3826. * @memberOf Stack
  3827. * @param {string} key The key of the value to remove.
  3828. * @returns {boolean} Returns `true` if the entry was removed, else `false`.
  3829. */
  3830. function stackDelete(key) {
  3831. var data = this.__data__,
  3832. result = data['delete'](key);
  3833. this.size = data.size;
  3834. return result;
  3835. }
  3836. /**
  3837. * Gets the stack value for `key`.
  3838. *
  3839. * @private
  3840. * @name get
  3841. * @memberOf Stack
  3842. * @param {string} key The key of the value to get.
  3843. * @returns {*} Returns the entry value.
  3844. */
  3845. function stackGet(key) {
  3846. return this.__data__.get(key);
  3847. }
  3848. /**
  3849. * Checks if a stack value for `key` exists.
  3850. *
  3851. * @private
  3852. * @name has
  3853. * @memberOf Stack
  3854. * @param {string} key The key of the entry to check.
  3855. * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
  3856. */
  3857. function stackHas(key) {
  3858. return this.__data__.has(key);
  3859. }
  3860. /**
  3861. * Sets the stack `key` to `value`.
  3862. *
  3863. * @private
  3864. * @name set
  3865. * @memberOf Stack
  3866. * @param {string} key The key of the value to set.
  3867. * @param {*} value The value to set.
  3868. * @returns {Object} Returns the stack cache instance.
  3869. */
  3870. function stackSet(key, value) {
  3871. var data = this.__data__;
  3872. if (data instanceof ListCache) {
  3873. var pairs = data.__data__;
  3874. if (!Map || (pairs.length < LARGE_ARRAY_SIZE - 1)) {
  3875. pairs.push([key, value]);
  3876. this.size = ++data.size;
  3877. return this;
  3878. }
  3879. data = this.__data__ = new MapCache(pairs);
  3880. }
  3881. data.set(key, value);
  3882. this.size = data.size;
  3883. return this;
  3884. }
  3885. // Add methods to `Stack`.
  3886. Stack.prototype.clear = stackClear;
  3887. Stack.prototype['delete'] = stackDelete;
  3888. Stack.prototype.get = stackGet;
  3889. Stack.prototype.has = stackHas;
  3890. Stack.prototype.set = stackSet;
  3891. /*------------------------------------------------------------------------*/
  3892. /**
  3893. * Creates an array of the enumerable property names of the array-like `value`.
  3894. *
  3895. * @private
  3896. * @param {*} value The value to query.
  3897. * @param {boolean} inherited Specify returning inherited property names.
  3898. * @returns {Array} Returns the array of property names.
  3899. */
  3900. function arrayLikeKeys(value, inherited) {
  3901. var isArr = isArray(value),
  3902. isArg = !isArr && isArguments(value),
  3903. isBuff = !isArr && !isArg && isBuffer(value),
  3904. isType = !isArr && !isArg && !isBuff && isTypedArray(value),
  3905. skipIndexes = isArr || isArg || isBuff || isType,
  3906. result = skipIndexes ? baseTimes(value.length, String) : [],
  3907. length = result.length;
  3908. for (var key in value) {
  3909. if ((inherited || hasOwnProperty.call(value, key)) &&
  3910. !(skipIndexes && (
  3911. // Safari 9 has enumerable `arguments.length` in strict mode.
  3912. key == 'length' ||
  3913. // Node.js 0.10 has enumerable non-index properties on buffers.
  3914. (isBuff && (key == 'offset' || key == 'parent')) ||
  3915. // PhantomJS 2 has enumerable non-index properties on typed arrays.
  3916. (isType && (key == 'buffer' || key == 'byteLength' || key == 'byteOffset')) ||
  3917. // Skip index properties.
  3918. isIndex(key, length)
  3919. ))) {
  3920. result.push(key);
  3921. }
  3922. }
  3923. return result;
  3924. }
  3925. /**
  3926. * A specialized version of `_.sample` for arrays.
  3927. *
  3928. * @private
  3929. * @param {Array} array The array to sample.
  3930. * @returns {*} Returns the random element.
  3931. */
  3932. function arraySample(array) {
  3933. var length = array.length;
  3934. return length ? array[baseRandom(0, length - 1)] : undefined;
  3935. }
  3936. /**
  3937. * A specialized version of `_.sampleSize` for arrays.
  3938. *
  3939. * @private
  3940. * @param {Array} array The array to sample.
  3941. * @param {number} n The number of elements to sample.
  3942. * @returns {Array} Returns the random elements.
  3943. */
  3944. function arraySampleSize(array, n) {
  3945. return shuffleSelf(copyArray(array), baseClamp(n, 0, array.length));
  3946. }
  3947. /**
  3948. * A specialized version of `_.shuffle` for arrays.
  3949. *
  3950. * @private
  3951. * @param {Array} array The array to shuffle.
  3952. * @returns {Array} Returns the new shuffled array.
  3953. */
  3954. function arrayShuffle(array) {
  3955. return shuffleSelf(copyArray(array));
  3956. }
  3957. /**
  3958. * This function is like `assignValue` except that it doesn't assign
  3959. * `undefined` values.
  3960. *
  3961. * @private
  3962. * @param {Object} object The object to modify.
  3963. * @param {string} key The key of the property to assign.
  3964. * @param {*} value The value to assign.
  3965. */
  3966. function assignMergeValue(object, key, value) {
  3967. if ((value !== undefined && !eq(object[key], value)) ||
  3968. (value === undefined && !(key in object))) {
  3969. baseAssignValue(object, key, value);
  3970. }
  3971. }
  3972. /**
  3973. * Assigns `value` to `key` of `object` if the existing value is not equivalent
  3974. * using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
  3975. * for equality comparisons.
  3976. *
  3977. * @private
  3978. * @param {Object} object The object to modify.
  3979. * @param {string} key The key of the property to assign.
  3980. * @param {*} value The value to assign.
  3981. */
  3982. function assignValue(object, key, value) {
  3983. var objValue = object[key];
  3984. if (!(hasOwnProperty.call(object, key) && eq(objValue, value)) ||
  3985. (value === undefined && !(key in object))) {
  3986. baseAssignValue(object, key, value);
  3987. }
  3988. }
  3989. /**
  3990. * Gets the index at which the `key` is found in `array` of key-value pairs.
  3991. *
  3992. * @private
  3993. * @param {Array} array The array to inspect.
  3994. * @param {*} key The key to search for.
  3995. * @returns {number} Returns the index of the matched value, else `-1`.
  3996. */
  3997. function assocIndexOf(array, key) {
  3998. var length = array.length;
  3999. while (length--) {
  4000. if (eq(array[length][0], key)) {
  4001. return length;
  4002. }
  4003. }
  4004. return -1;
  4005. }
  4006. /**
  4007. * Aggregates elements of `collection` on `accumulator` with keys transformed
  4008. * by `iteratee` and values set by `setter`.
  4009. *
  4010. * @private
  4011. * @param {Array|Object} collection The collection to iterate over.
  4012. * @param {Function} setter The function to set `accumulator` values.
  4013. * @param {Function} iteratee The iteratee to transform keys.
  4014. * @param {Object} accumulator The initial aggregated object.
  4015. * @returns {Function} Returns `accumulator`.
  4016. */
  4017. function baseAggregator(collection, setter, iteratee, accumulator) {
  4018. baseEach(collection, function(value, key, collection) {
  4019. setter(accumulator, value, iteratee(value), collection);
  4020. });
  4021. return accumulator;
  4022. }
  4023. /**
  4024. * The base implementation of `_.assign` without support for multiple sources
  4025. * or `customizer` functions.
  4026. *
  4027. * @private
  4028. * @param {Object} object The destination object.
  4029. * @param {Object} source The source object.
  4030. * @returns {Object} Returns `object`.
  4031. */
  4032. function baseAssign(object, source) {
  4033. return object && copyObject(source, keys(source), object);
  4034. }
  4035. /**
  4036. * The base implementation of `_.assignIn` without support for multiple sources
  4037. * or `customizer` functions.
  4038. *
  4039. * @private
  4040. * @param {Object} object The destination object.
  4041. * @param {Object} source The source object.
  4042. * @returns {Object} Returns `object`.
  4043. */
  4044. function baseAssignIn(object, source) {
  4045. return object && copyObject(source, keysIn(source), object);
  4046. }
  4047. /**
  4048. * The base implementation of `assignValue` and `assignMergeValue` without
  4049. * value checks.
  4050. *
  4051. * @private
  4052. * @param {Object} object The object to modify.
  4053. * @param {string} key The key of the property to assign.
  4054. * @param {*} value The value to assign.
  4055. */
  4056. function baseAssignValue(object, key, value) {
  4057. if (key == '__proto__' && defineProperty) {
  4058. defineProperty(object, key, {
  4059. 'configurable': true,
  4060. 'enumerable': true,
  4061. 'value': value,
  4062. 'writable': true
  4063. });
  4064. } else {
  4065. object[key] = value;
  4066. }
  4067. }
  4068. /**
  4069. * The base implementation of `_.at` without support for individual paths.
  4070. *
  4071. * @private
  4072. * @param {Object} object The object to iterate over.
  4073. * @param {string[]} paths The property paths to pick.
  4074. * @returns {Array} Returns the picked elements.
  4075. */
  4076. function baseAt(object, paths) {
  4077. var index = -1,
  4078. length = paths.length,
  4079. result = Array(length),
  4080. skip = object == null;
  4081. while (++index < length) {
  4082. result[index] = skip ? undefined : get(object, paths[index]);
  4083. }
  4084. return result;
  4085. }
  4086. /**
  4087. * The base implementation of `_.clamp` which doesn't coerce arguments.
  4088. *
  4089. * @private
  4090. * @param {number} number The number to clamp.
  4091. * @param {number} [lower] The lower bound.
  4092. * @param {number} upper The upper bound.
  4093. * @returns {number} Returns the clamped number.
  4094. */
  4095. function baseClamp(number, lower, upper) {
  4096. if (number === number) {
  4097. if (upper !== undefined) {
  4098. number = number <= upper ? number : upper;
  4099. }
  4100. if (lower !== undefined) {
  4101. number = number >= lower ? number : lower;
  4102. }
  4103. }
  4104. return number;
  4105. }
  4106. /**
  4107. * The base implementation of `_.clone` and `_.cloneDeep` which tracks
  4108. * traversed objects.
  4109. *
  4110. * @private
  4111. * @param {*} value The value to clone.
  4112. * @param {boolean} bitmask The bitmask flags.
  4113. * 1 - Deep clone
  4114. * 2 - Flatten inherited properties
  4115. * 4 - Clone symbols
  4116. * @param {Function} [customizer] The function to customize cloning.
  4117. * @param {string} [key] The key of `value`.
  4118. * @param {Object} [object] The parent object of `value`.
  4119. * @param {Object} [stack] Tracks traversed objects and their clone counterparts.
  4120. * @returns {*} Returns the cloned value.
  4121. */
  4122. function baseClone(value, bitmask, customizer, key, object, stack) {
  4123. var result,
  4124. isDeep = bitmask & CLONE_DEEP_FLAG,
  4125. isFlat = bitmask & CLONE_FLAT_FLAG,
  4126. isFull = bitmask & CLONE_SYMBOLS_FLAG;
  4127. if (customizer) {
  4128. result = object ? customizer(value, key, object, stack) : customizer(value);
  4129. }
  4130. if (result !== undefined) {
  4131. return result;
  4132. }
  4133. if (!isObject(value)) {
  4134. return value;
  4135. }
  4136. var isArr = isArray(value);
  4137. if (isArr) {
  4138. result = initCloneArray(value);
  4139. if (!isDeep) {
  4140. return copyArray(value, result);
  4141. }
  4142. } else {
  4143. var tag = getTag(value),
  4144. isFunc = tag == funcTag || tag == genTag;
  4145. if (isBuffer(value)) {
  4146. return cloneBuffer(value, isDeep);
  4147. }
  4148. if (tag == objectTag || tag == argsTag || (isFunc && !object)) {
  4149. result = (isFlat || isFunc) ? {} : initCloneObject(value);
  4150. if (!isDeep) {
  4151. return isFlat
  4152. ? copySymbolsIn(value, baseAssignIn(result, value))
  4153. : copySymbols(value, baseAssign(result, value));
  4154. }
  4155. } else {
  4156. if (!cloneableTags[tag]) {
  4157. return object ? value : {};
  4158. }
  4159. result = initCloneByTag(value, tag, isDeep);
  4160. }
  4161. }
  4162. // Check for circular references and return its corresponding clone.
  4163. stack || (stack = new Stack);
  4164. var stacked = stack.get(value);
  4165. if (stacked) {
  4166. return stacked;
  4167. }
  4168. stack.set(value, result);
  4169. if (isSet(value)) {
  4170. value.forEach(function(subValue) {
  4171. result.add(baseClone(subValue, bitmask, customizer, subValue, value, stack));
  4172. });
  4173. } else if (isMap(value)) {
  4174. value.forEach(function(subValue, key) {
  4175. result.set(key, baseClone(subValue, bitmask, customizer, key, value, stack));
  4176. });
  4177. }
  4178. var keysFunc = isFull
  4179. ? (isFlat ? getAllKeysIn : getAllKeys)
  4180. : (isFlat ? keysIn : keys);
  4181. var props = isArr ? undefined : keysFunc(value);
  4182. arrayEach(props || value, function(subValue, key) {
  4183. if (props) {
  4184. key = subValue;
  4185. subValue = value[key];
  4186. }
  4187. // Recursively populate clone (susceptible to call stack limits).
  4188. assignValue(result, key, baseClone(subValue, bitmask, customizer, key, value, stack));
  4189. });
  4190. return result;
  4191. }
  4192. /**
  4193. * The base implementation of `_.conforms` which doesn't clone `source`.
  4194. *
  4195. * @private
  4196. * @param {Object} source The object of property predicates to conform to.
  4197. * @returns {Function} Returns the new spec function.
  4198. */
  4199. function baseConforms(source) {
  4200. var props = keys(source);
  4201. return function(object) {
  4202. return baseConformsTo(object, source, props);
  4203. };
  4204. }
  4205. /**
  4206. * The base implementation of `_.conformsTo` which accepts `props` to check.
  4207. *
  4208. * @private
  4209. * @param {Object} object The object to inspect.
  4210. * @param {Object} source The object of property predicates to conform to.
  4211. * @returns {boolean} Returns `true` if `object` conforms, else `false`.
  4212. */
  4213. function baseConformsTo(object, source, props) {
  4214. var length = props.length;
  4215. if (object == null) {
  4216. return !length;
  4217. }
  4218. object = Object(object);
  4219. while (length--) {
  4220. var key = props[length],
  4221. predicate = source[key],
  4222. value = object[key];
  4223. if ((value === undefined && !(key in object)) || !predicate(value)) {
  4224. return false;
  4225. }
  4226. }
  4227. return true;
  4228. }
  4229. /**
  4230. * The base implementation of `_.delay` and `_.defer` which accepts `args`
  4231. * to provide to `func`.
  4232. *
  4233. * @private
  4234. * @param {Function} func The function to delay.
  4235. * @param {number} wait The number of milliseconds to delay invocation.
  4236. * @param {Array} args The arguments to provide to `func`.
  4237. * @returns {number|Object} Returns the timer id or timeout object.
  4238. */
  4239. function baseDelay(func, wait, args) {
  4240. if (typeof func != 'function') {
  4241. throw new TypeError(FUNC_ERROR_TEXT);
  4242. }
  4243. return setTimeout(function() { func.apply(undefined, args); }, wait);
  4244. }
  4245. /**
  4246. * The base implementation of methods like `_.difference` without support
  4247. * for excluding multiple arrays or iteratee shorthands.
  4248. *
  4249. * @private
  4250. * @param {Array} array The array to inspect.
  4251. * @param {Array} values The values to exclude.
  4252. * @param {Function} [iteratee] The iteratee invoked per element.
  4253. * @param {Function} [comparator] The comparator invoked per element.
  4254. * @returns {Array} Returns the new array of filtered values.
  4255. */
  4256. function baseDifference(array, values, iteratee, comparator) {
  4257. var index = -1,
  4258. includes = arrayIncludes,
  4259. isCommon = true,
  4260. length = array.length,
  4261. result = [],
  4262. valuesLength = values.length;
  4263. if (!length) {
  4264. return result;
  4265. }
  4266. if (iteratee) {
  4267. values = arrayMap(values, baseUnary(iteratee));
  4268. }
  4269. if (comparator) {
  4270. includes = arrayIncludesWith;
  4271. isCommon = false;
  4272. }
  4273. else if (values.length >= LARGE_ARRAY_SIZE) {
  4274. includes = cacheHas;
  4275. isCommon = false;
  4276. values = new SetCache(values);
  4277. }
  4278. outer:
  4279. while (++index < length) {
  4280. var value = array[index],
  4281. computed = iteratee == null ? value : iteratee(value);
  4282. value = (comparator || value !== 0) ? value : 0;
  4283. if (isCommon && computed === computed) {
  4284. var valuesIndex = valuesLength;
  4285. while (valuesIndex--) {
  4286. if (values[valuesIndex] === computed) {
  4287. continue outer;
  4288. }
  4289. }
  4290. result.push(value);
  4291. }
  4292. else if (!includes(values, computed, comparator)) {
  4293. result.push(value);
  4294. }
  4295. }
  4296. return result;
  4297. }
  4298. /**
  4299. * The base implementation of `_.forEach` without support for iteratee shorthands.
  4300. *
  4301. * @private
  4302. * @param {Array|Object} collection The collection to iterate over.
  4303. * @param {Function} iteratee The function invoked per iteration.
  4304. * @returns {Array|Object} Returns `collection`.
  4305. */
  4306. var baseEach = createBaseEach(baseForOwn);
  4307. /**
  4308. * The base implementation of `_.forEachRight` without support for iteratee shorthands.
  4309. *
  4310. * @private
  4311. * @param {Array|Object} collection The collection to iterate over.
  4312. * @param {Function} iteratee The function invoked per iteration.
  4313. * @returns {Array|Object} Returns `collection`.
  4314. */
  4315. var baseEachRight = createBaseEach(baseForOwnRight, true);
  4316. /**
  4317. * The base implementation of `_.every` without support for iteratee shorthands.
  4318. *
  4319. * @private
  4320. * @param {Array|Object} collection The collection to iterate over.
  4321. * @param {Function} predicate The function invoked per iteration.
  4322. * @returns {boolean} Returns `true` if all elements pass the predicate check,
  4323. * else `false`
  4324. */
  4325. function baseEvery(collection, predicate) {
  4326. var result = true;
  4327. baseEach(collection, function(value, index, collection) {
  4328. result = !!predicate(value, index, collection);
  4329. return result;
  4330. });
  4331. return result;
  4332. }
  4333. /**
  4334. * The base implementation of methods like `_.max` and `_.min` which accepts a
  4335. * `comparator` to determine the extremum value.
  4336. *
  4337. * @private
  4338. * @param {Array} array The array to iterate over.
  4339. * @param {Function} iteratee The iteratee invoked per iteration.
  4340. * @param {Function} comparator The comparator used to compare values.
  4341. * @returns {*} Returns the extremum value.
  4342. */
  4343. function baseExtremum(array, iteratee, comparator) {
  4344. var index = -1,
  4345. length = array.length;
  4346. while (++index < length) {
  4347. var value = array[index],
  4348. current = iteratee(value);
  4349. if (current != null && (computed === undefined
  4350. ? (current === current && !isSymbol(current))
  4351. : comparator(current, computed)
  4352. )) {
  4353. var computed = current,
  4354. result = value;
  4355. }
  4356. }
  4357. return result;
  4358. }
  4359. /**
  4360. * The base implementation of `_.fill` without an iteratee call guard.
  4361. *
  4362. * @private
  4363. * @param {Array} array The array to fill.
  4364. * @param {*} value The value to fill `array` with.
  4365. * @param {number} [start=0] The start position.
  4366. * @param {number} [end=array.length] The end position.
  4367. * @returns {Array} Returns `array`.
  4368. */
  4369. function baseFill(array, value, start, end) {
  4370. var length = array.length;
  4371. start = toInteger(start);
  4372. if (start < 0) {
  4373. start = -start > length ? 0 : (length + start);
  4374. }
  4375. end = (end === undefined || end > length) ? length : toInteger(end);
  4376. if (end < 0) {
  4377. end += length;
  4378. }
  4379. end = start > end ? 0 : toLength(end);
  4380. while (start < end) {
  4381. array[start++] = value;
  4382. }
  4383. return array;
  4384. }
  4385. /**
  4386. * The base implementation of `_.filter` without support for iteratee shorthands.
  4387. *
  4388. * @private
  4389. * @param {Array|Object} collection The collection to iterate over.
  4390. * @param {Function} predicate The function invoked per iteration.
  4391. * @returns {Array} Returns the new filtered array.
  4392. */
  4393. function baseFilter(collection, predicate) {
  4394. var result = [];
  4395. baseEach(collection, function(value, index, collection) {
  4396. if (predicate(value, index, collection)) {
  4397. result.push(value);
  4398. }
  4399. });
  4400. return result;
  4401. }
  4402. /**
  4403. * The base implementation of `_.flatten` with support for restricting flattening.
  4404. *
  4405. * @private
  4406. * @param {Array} array The array to flatten.
  4407. * @param {number} depth The maximum recursion depth.
  4408. * @param {boolean} [predicate=isFlattenable] The function invoked per iteration.
  4409. * @param {boolean} [isStrict] Restrict to values that pass `predicate` checks.
  4410. * @param {Array} [result=[]] The initial result value.
  4411. * @returns {Array} Returns the new flattened array.
  4412. */
  4413. function baseFlatten(array, depth, predicate, isStrict, result) {
  4414. var index = -1,
  4415. length = array.length;
  4416. predicate || (predicate = isFlattenable);
  4417. result || (result = []);
  4418. while (++index < length) {
  4419. var value = array[index];
  4420. if (depth > 0 && predicate(value)) {
  4421. if (depth > 1) {
  4422. // Recursively flatten arrays (susceptible to call stack limits).
  4423. baseFlatten(value, depth - 1, predicate, isStrict, result);
  4424. } else {
  4425. arrayPush(result, value);
  4426. }
  4427. } else if (!isStrict) {
  4428. result[result.length] = value;
  4429. }
  4430. }
  4431. return result;
  4432. }
  4433. /**
  4434. * The base implementation of `baseForOwn` which iterates over `object`
  4435. * properties returned by `keysFunc` and invokes `iteratee` for each property.
  4436. * Iteratee functions may exit iteration early by explicitly returning `false`.
  4437. *
  4438. * @private
  4439. * @param {Object} object The object to iterate over.
  4440. * @param {Function} iteratee The function invoked per iteration.
  4441. * @param {Function} keysFunc The function to get the keys of `object`.
  4442. * @returns {Object} Returns `object`.
  4443. */
  4444. var baseFor = createBaseFor();
  4445. /**
  4446. * This function is like `baseFor` except that it iterates over properties
  4447. * in the opposite order.
  4448. *
  4449. * @private
  4450. * @param {Object} object The object to iterate over.
  4451. * @param {Function} iteratee The function invoked per iteration.
  4452. * @param {Function} keysFunc The function to get the keys of `object`.
  4453. * @returns {Object} Returns `object`.
  4454. */
  4455. var baseForRight = createBaseFor(true);
  4456. /**
  4457. * The base implementation of `_.forOwn` without support for iteratee shorthands.
  4458. *
  4459. * @private
  4460. * @param {Object} object The object to iterate over.
  4461. * @param {Function} iteratee The function invoked per iteration.
  4462. * @returns {Object} Returns `object`.
  4463. */
  4464. function baseForOwn(object, iteratee) {
  4465. return object && baseFor(object, iteratee, keys);
  4466. }
  4467. /**
  4468. * The base implementation of `_.forOwnRight` without support for iteratee shorthands.
  4469. *
  4470. * @private
  4471. * @param {Object} object The object to iterate over.
  4472. * @param {Function} iteratee The function invoked per iteration.
  4473. * @returns {Object} Returns `object`.
  4474. */
  4475. function baseForOwnRight(object, iteratee) {
  4476. return object && baseForRight(object, iteratee, keys);
  4477. }
  4478. /**
  4479. * The base implementation of `_.functions` which creates an array of
  4480. * `object` function property names filtered from `props`.
  4481. *
  4482. * @private
  4483. * @param {Object} object The object to inspect.
  4484. * @param {Array} props The property names to filter.
  4485. * @returns {Array} Returns the function names.
  4486. */
  4487. function baseFunctions(object, props) {
  4488. return arrayFilter(props, function(key) {
  4489. return isFunction(object[key]);
  4490. });
  4491. }
  4492. /**
  4493. * The base implementation of `_.get` without support for default values.
  4494. *
  4495. * @private
  4496. * @param {Object} object The object to query.
  4497. * @param {Array|string} path The path of the property to get.
  4498. * @returns {*} Returns the resolved value.
  4499. */
  4500. function baseGet(object, path) {
  4501. path = castPath(path, object);
  4502. var index = 0,
  4503. length = path.length;
  4504. while (object != null && index < length) {
  4505. object = object[toKey(path[index++])];
  4506. }
  4507. return (index && index == length) ? object : undefined;
  4508. }
  4509. /**
  4510. * The base implementation of `getAllKeys` and `getAllKeysIn` which uses
  4511. * `keysFunc` and `symbolsFunc` to get the enumerable property names and
  4512. * symbols of `object`.
  4513. *
  4514. * @private
  4515. * @param {Object} object The object to query.
  4516. * @param {Function} keysFunc The function to get the keys of `object`.
  4517. * @param {Function} symbolsFunc The function to get the symbols of `object`.
  4518. * @returns {Array} Returns the array of property names and symbols.
  4519. */
  4520. function baseGetAllKeys(object, keysFunc, symbolsFunc) {
  4521. var result = keysFunc(object);
  4522. return isArray(object) ? result : arrayPush(result, symbolsFunc(object));
  4523. }
  4524. /**
  4525. * The base implementation of `getTag` without fallbacks for buggy environments.
  4526. *
  4527. * @private
  4528. * @param {*} value The value to query.
  4529. * @returns {string} Returns the `toStringTag`.
  4530. */
  4531. function baseGetTag(value) {
  4532. if (value == null) {
  4533. return value === undefined ? undefinedTag : nullTag;
  4534. }
  4535. return (symToStringTag && symToStringTag in Object(value))
  4536. ? getRawTag(value)
  4537. : objectToString(value);
  4538. }
  4539. /**
  4540. * The base implementation of `_.gt` which doesn't coerce arguments.
  4541. *
  4542. * @private
  4543. * @param {*} value The value to compare.
  4544. * @param {*} other The other value to compare.
  4545. * @returns {boolean} Returns `true` if `value` is greater than `other`,
  4546. * else `false`.
  4547. */
  4548. function baseGt(value, other) {
  4549. return value > other;
  4550. }
  4551. /**
  4552. * The base implementation of `_.has` without support for deep paths.
  4553. *
  4554. * @private
  4555. * @param {Object} [object] The object to query.
  4556. * @param {Array|string} key The key to check.
  4557. * @returns {boolean} Returns `true` if `key` exists, else `false`.
  4558. */
  4559. function baseHas(object, key) {
  4560. return object != null && hasOwnProperty.call(object, key);
  4561. }
  4562. /**
  4563. * The base implementation of `_.hasIn` without support for deep paths.
  4564. *
  4565. * @private
  4566. * @param {Object} [object] The object to query.
  4567. * @param {Array|string} key The key to check.
  4568. * @returns {boolean} Returns `true` if `key` exists, else `false`.
  4569. */
  4570. function baseHasIn(object, key) {
  4571. return object != null && key in Object(object);
  4572. }
  4573. /**
  4574. * The base implementation of `_.inRange` which doesn't coerce arguments.
  4575. *
  4576. * @private
  4577. * @param {number} number The number to check.
  4578. * @param {number} start The start of the range.
  4579. * @param {number} end The end of the range.
  4580. * @returns {boolean} Returns `true` if `number` is in the range, else `false`.
  4581. */
  4582. function baseInRange(number, start, end) {
  4583. return number >= nativeMin(start, end) && number < nativeMax(start, end);
  4584. }
  4585. /**
  4586. * The base implementation of methods like `_.intersection`, without support
  4587. * for iteratee shorthands, that accepts an array of arrays to inspect.
  4588. *
  4589. * @private
  4590. * @param {Array} arrays The arrays to inspect.
  4591. * @param {Function} [iteratee] The iteratee invoked per element.
  4592. * @param {Function} [comparator] The comparator invoked per element.
  4593. * @returns {Array} Returns the new array of shared values.
  4594. */
  4595. function baseIntersection(arrays, iteratee, comparator) {
  4596. var includes = comparator ? arrayIncludesWith : arrayIncludes,
  4597. length = arrays[0].length,
  4598. othLength = arrays.length,
  4599. othIndex = othLength,
  4600. caches = Array(othLength),
  4601. maxLength = Infinity,
  4602. result = [];
  4603. while (othIndex--) {
  4604. var array = arrays[othIndex];
  4605. if (othIndex && iteratee) {
  4606. array = arrayMap(array, baseUnary(iteratee));
  4607. }
  4608. maxLength = nativeMin(array.length, maxLength);
  4609. caches[othIndex] = !comparator && (iteratee || (length >= 120 && array.length >= 120))
  4610. ? new SetCache(othIndex && array)
  4611. : undefined;
  4612. }
  4613. array = arrays[0];
  4614. var index = -1,
  4615. seen = caches[0];
  4616. outer:
  4617. while (++index < length && result.length < maxLength) {
  4618. var value = array[index],
  4619. computed = iteratee ? iteratee(value) : value;
  4620. value = (comparator || value !== 0) ? value : 0;
  4621. if (!(seen
  4622. ? cacheHas(seen, computed)
  4623. : includes(result, computed, comparator)
  4624. )) {
  4625. othIndex = othLength;
  4626. while (--othIndex) {
  4627. var cache = caches[othIndex];
  4628. if (!(cache
  4629. ? cacheHas(cache, computed)
  4630. : includes(arrays[othIndex], computed, comparator))
  4631. ) {
  4632. continue outer;
  4633. }
  4634. }
  4635. if (seen) {
  4636. seen.push(computed);
  4637. }
  4638. result.push(value);
  4639. }
  4640. }
  4641. return result;
  4642. }
  4643. /**
  4644. * The base implementation of `_.invert` and `_.invertBy` which inverts
  4645. * `object` with values transformed by `iteratee` and set by `setter`.
  4646. *
  4647. * @private
  4648. * @param {Object} object The object to iterate over.
  4649. * @param {Function} setter The function to set `accumulator` values.
  4650. * @param {Function} iteratee The iteratee to transform values.
  4651. * @param {Object} accumulator The initial inverted object.
  4652. * @returns {Function} Returns `accumulator`.
  4653. */
  4654. function baseInverter(object, setter, iteratee, accumulator) {
  4655. baseForOwn(object, function(value, key, object) {
  4656. setter(accumulator, iteratee(value), key, object);
  4657. });
  4658. return accumulator;
  4659. }
  4660. /**
  4661. * The base implementation of `_.invoke` without support for individual
  4662. * method arguments.
  4663. *
  4664. * @private
  4665. * @param {Object} object The object to query.
  4666. * @param {Array|string} path The path of the method to invoke.
  4667. * @param {Array} args The arguments to invoke the method with.
  4668. * @returns {*} Returns the result of the invoked method.
  4669. */
  4670. function baseInvoke(object, path, args) {
  4671. path = castPath(path, object);
  4672. object = parent(object, path);
  4673. var func = object == null ? object : object[toKey(last(path))];
  4674. return func == null ? undefined : apply(func, object, args);
  4675. }
  4676. /**
  4677. * The base implementation of `_.isArguments`.
  4678. *
  4679. * @private
  4680. * @param {*} value The value to check.
  4681. * @returns {boolean} Returns `true` if `value` is an `arguments` object,
  4682. */
  4683. function baseIsArguments(value) {
  4684. return isObjectLike(value) && baseGetTag(value) == argsTag;
  4685. }
  4686. /**
  4687. * The base implementation of `_.isArrayBuffer` without Node.js optimizations.
  4688. *
  4689. * @private
  4690. * @param {*} value The value to check.
  4691. * @returns {boolean} Returns `true` if `value` is an array buffer, else `false`.
  4692. */
  4693. function baseIsArrayBuffer(value) {
  4694. return isObjectLike(value) && baseGetTag(value) == arrayBufferTag;
  4695. }
  4696. /**
  4697. * The base implementation of `_.isDate` without Node.js optimizations.
  4698. *
  4699. * @private
  4700. * @param {*} value The value to check.
  4701. * @returns {boolean} Returns `true` if `value` is a date object, else `false`.
  4702. */
  4703. function baseIsDate(value) {
  4704. return isObjectLike(value) && baseGetTag(value) == dateTag;
  4705. }
  4706. /**
  4707. * The base implementation of `_.isEqual` which supports partial comparisons
  4708. * and tracks traversed objects.
  4709. *
  4710. * @private
  4711. * @param {*} value The value to compare.
  4712. * @param {*} other The other value to compare.
  4713. * @param {boolean} bitmask The bitmask flags.
  4714. * 1 - Unordered comparison
  4715. * 2 - Partial comparison
  4716. * @param {Function} [customizer] The function to customize comparisons.
  4717. * @param {Object} [stack] Tracks traversed `value` and `other` objects.
  4718. * @returns {boolean} Returns `true` if the values are equivalent, else `false`.
  4719. */
  4720. function baseIsEqual(value, other, bitmask, customizer, stack) {
  4721. if (value === other) {
  4722. return true;
  4723. }
  4724. if (value == null || other == null || (!isObjectLike(value) && !isObjectLike(other))) {
  4725. return value !== value && other !== other;
  4726. }
  4727. return baseIsEqualDeep(value, other, bitmask, customizer, baseIsEqual, stack);
  4728. }
  4729. /**
  4730. * A specialized version of `baseIsEqual` for arrays and objects which performs
  4731. * deep comparisons and tracks traversed objects enabling objects with circular
  4732. * references to be compared.
  4733. *
  4734. * @private
  4735. * @param {Object} object The object to compare.
  4736. * @param {Object} other The other object to compare.
  4737. * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.
  4738. * @param {Function} customizer The function to customize comparisons.
  4739. * @param {Function} equalFunc The function to determine equivalents of values.
  4740. * @param {Object} [stack] Tracks traversed `object` and `other` objects.
  4741. * @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
  4742. */
  4743. function baseIsEqualDeep(object, other, bitmask, customizer, equalFunc, stack) {
  4744. var objIsArr = isArray(object),
  4745. othIsArr = isArray(other),
  4746. objTag = objIsArr ? arrayTag : getTag(object),
  4747. othTag = othIsArr ? arrayTag : getTag(other);
  4748. objTag = objTag == argsTag ? objectTag : objTag;
  4749. othTag = othTag == argsTag ? objectTag : othTag;
  4750. var objIsObj = objTag == objectTag,
  4751. othIsObj = othTag == objectTag,
  4752. isSameTag = objTag == othTag;
  4753. if (isSameTag && isBuffer(object)) {
  4754. if (!isBuffer(other)) {
  4755. return false;
  4756. }
  4757. objIsArr = true;
  4758. objIsObj = false;
  4759. }
  4760. if (isSameTag && !objIsObj) {
  4761. stack || (stack = new Stack);
  4762. return (objIsArr || isTypedArray(object))
  4763. ? equalArrays(object, other, bitmask, customizer, equalFunc, stack)
  4764. : equalByTag(object, other, objTag, bitmask, customizer, equalFunc, stack);
  4765. }
  4766. if (!(bitmask & COMPARE_PARTIAL_FLAG)) {
  4767. var objIsWrapped = objIsObj && hasOwnProperty.call(object, '__wrapped__'),
  4768. othIsWrapped = othIsObj && hasOwnProperty.call(other, '__wrapped__');
  4769. if (objIsWrapped || othIsWrapped) {
  4770. var objUnwrapped = objIsWrapped ? object.value() : object,
  4771. othUnwrapped = othIsWrapped ? other.value() : other;
  4772. stack || (stack = new Stack);
  4773. return equalFunc(objUnwrapped, othUnwrapped, bitmask, customizer, stack);
  4774. }
  4775. }
  4776. if (!isSameTag) {
  4777. return false;
  4778. }
  4779. stack || (stack = new Stack);
  4780. return equalObjects(object, other, bitmask, customizer, equalFunc, stack);
  4781. }
  4782. /**
  4783. * The base implementation of `_.isMap` without Node.js optimizations.
  4784. *
  4785. * @private
  4786. * @param {*} value The value to check.
  4787. * @returns {boolean} Returns `true` if `value` is a map, else `false`.
  4788. */
  4789. function baseIsMap(value) {
  4790. return isObjectLike(value) && getTag(value) == mapTag;
  4791. }
  4792. /**
  4793. * The base implementation of `_.isMatch` without support for iteratee shorthands.
  4794. *
  4795. * @private
  4796. * @param {Object} object The object to inspect.
  4797. * @param {Object} source The object of property values to match.
  4798. * @param {Array} matchData The property names, values, and compare flags to match.
  4799. * @param {Function} [customizer] The function to customize comparisons.
  4800. * @returns {boolean} Returns `true` if `object` is a match, else `false`.
  4801. */
  4802. function baseIsMatch(object, source, matchData, customizer) {
  4803. var index = matchData.length,
  4804. length = index,
  4805. noCustomizer = !customizer;
  4806. if (object == null) {
  4807. return !length;
  4808. }
  4809. object = Object(object);
  4810. while (index--) {
  4811. var data = matchData[index];
  4812. if ((noCustomizer && data[2])
  4813. ? data[1] !== object[data[0]]
  4814. : !(data[0] in object)
  4815. ) {
  4816. return false;
  4817. }
  4818. }
  4819. while (++index < length) {
  4820. data = matchData[index];
  4821. var key = data[0],
  4822. objValue = object[key],
  4823. srcValue = data[1];
  4824. if (noCustomizer && data[2]) {
  4825. if (objValue === undefined && !(key in object)) {
  4826. return false;
  4827. }
  4828. } else {
  4829. var stack = new Stack;
  4830. if (customizer) {
  4831. var result = customizer(objValue, srcValue, key, object, source, stack);
  4832. }
  4833. if (!(result === undefined
  4834. ? baseIsEqual(srcValue, objValue, COMPARE_PARTIAL_FLAG | COMPARE_UNORDERED_FLAG, customizer, stack)
  4835. : result
  4836. )) {
  4837. return false;
  4838. }
  4839. }
  4840. }
  4841. return true;
  4842. }
  4843. /**
  4844. * The base implementation of `_.isNative` without bad shim checks.
  4845. *
  4846. * @private
  4847. * @param {*} value The value to check.
  4848. * @returns {boolean} Returns `true` if `value` is a native function,
  4849. * else `false`.
  4850. */
  4851. function baseIsNative(value) {
  4852. if (!isObject(value) || isMasked(value)) {
  4853. return false;
  4854. }
  4855. var pattern = isFunction(value) ? reIsNative : reIsHostCtor;
  4856. return pattern.test(toSource(value));
  4857. }
  4858. /**
  4859. * The base implementation of `_.isRegExp` without Node.js optimizations.
  4860. *
  4861. * @private
  4862. * @param {*} value The value to check.
  4863. * @returns {boolean} Returns `true` if `value` is a regexp, else `false`.
  4864. */
  4865. function baseIsRegExp(value) {
  4866. return isObjectLike(value) && baseGetTag(value) == regexpTag;
  4867. }
  4868. /**
  4869. * The base implementation of `_.isSet` without Node.js optimizations.
  4870. *
  4871. * @private
  4872. * @param {*} value The value to check.
  4873. * @returns {boolean} Returns `true` if `value` is a set, else `false`.
  4874. */
  4875. function baseIsSet(value) {
  4876. return isObjectLike(value) && getTag(value) == setTag;
  4877. }
  4878. /**
  4879. * The base implementation of `_.isTypedArray` without Node.js optimizations.
  4880. *
  4881. * @private
  4882. * @param {*} value The value to check.
  4883. * @returns {boolean} Returns `true` if `value` is a typed array, else `false`.
  4884. */
  4885. function baseIsTypedArray(value) {
  4886. return isObjectLike(value) &&
  4887. isLength(value.length) && !!typedArrayTags[baseGetTag(value)];
  4888. }
  4889. /**
  4890. * The base implementation of `_.iteratee`.
  4891. *
  4892. * @private
  4893. * @param {*} [value=_.identity] The value to convert to an iteratee.
  4894. * @returns {Function} Returns the iteratee.
  4895. */
  4896. function baseIteratee(value) {
  4897. // Don't store the `typeof` result in a variable to avoid a JIT bug in Safari 9.
  4898. // See https://bugs.webkit.org/show_bug.cgi?id=156034 for more details.
  4899. if (typeof value == 'function') {
  4900. return value;
  4901. }
  4902. if (value == null) {
  4903. return identity;
  4904. }
  4905. if (typeof value == 'object') {
  4906. return isArray(value)
  4907. ? baseMatchesProperty(value[0], value[1])
  4908. : baseMatches(value);
  4909. }
  4910. return property(value);
  4911. }
  4912. /**
  4913. * The base implementation of `_.keys` which doesn't treat sparse arrays as dense.
  4914. *
  4915. * @private
  4916. * @param {Object} object The object to query.
  4917. * @returns {Array} Returns the array of property names.
  4918. */
  4919. function baseKeys(object) {
  4920. if (!isPrototype(object)) {
  4921. return nativeKeys(object);
  4922. }
  4923. var result = [];
  4924. for (var key in Object(object)) {
  4925. if (hasOwnProperty.call(object, key) && key != 'constructor') {
  4926. result.push(key);
  4927. }
  4928. }
  4929. return result;
  4930. }
  4931. /**
  4932. * The base implementation of `_.keysIn` which doesn't treat sparse arrays as dense.
  4933. *
  4934. * @private
  4935. * @param {Object} object The object to query.
  4936. * @returns {Array} Returns the array of property names.
  4937. */
  4938. function baseKeysIn(object) {
  4939. if (!isObject(object)) {
  4940. return nativeKeysIn(object);
  4941. }
  4942. var isProto = isPrototype(object),
  4943. result = [];
  4944. for (var key in object) {
  4945. if (!(key == 'constructor' && (isProto || !hasOwnProperty.call(object, key)))) {
  4946. result.push(key);
  4947. }
  4948. }
  4949. return result;
  4950. }
  4951. /**
  4952. * The base implementation of `_.lt` which doesn't coerce arguments.
  4953. *
  4954. * @private
  4955. * @param {*} value The value to compare.
  4956. * @param {*} other The other value to compare.
  4957. * @returns {boolean} Returns `true` if `value` is less than `other`,
  4958. * else `false`.
  4959. */
  4960. function baseLt(value, other) {
  4961. return value < other;
  4962. }
  4963. /**
  4964. * The base implementation of `_.map` without support for iteratee shorthands.
  4965. *
  4966. * @private
  4967. * @param {Array|Object} collection The collection to iterate over.
  4968. * @param {Function} iteratee The function invoked per iteration.
  4969. * @returns {Array} Returns the new mapped array.
  4970. */
  4971. function baseMap(collection, iteratee) {
  4972. var index = -1,
  4973. result = isArrayLike(collection) ? Array(collection.length) : [];
  4974. baseEach(collection, function(value, key, collection) {
  4975. result[++index] = iteratee(value, key, collection);
  4976. });
  4977. return result;
  4978. }
  4979. /**
  4980. * The base implementation of `_.matches` which doesn't clone `source`.
  4981. *
  4982. * @private
  4983. * @param {Object} source The object of property values to match.
  4984. * @returns {Function} Returns the new spec function.
  4985. */
  4986. function baseMatches(source) {
  4987. var matchData = getMatchData(source);
  4988. if (matchData.length == 1 && matchData[0][2]) {
  4989. return matchesStrictComparable(matchData[0][0], matchData[0][1]);
  4990. }
  4991. return function(object) {
  4992. return object === source || baseIsMatch(object, source, matchData);
  4993. };
  4994. }
  4995. /**
  4996. * The base implementation of `_.matchesProperty` which doesn't clone `srcValue`.
  4997. *
  4998. * @private
  4999. * @param {string} path The path of the property to get.
  5000. * @param {*} srcValue The value to match.
  5001. * @returns {Function} Returns the new spec function.
  5002. */
  5003. function baseMatchesProperty(path, srcValue) {
  5004. if (isKey(path) && isStrictComparable(srcValue)) {
  5005. return matchesStrictComparable(toKey(path), srcValue);
  5006. }
  5007. return function(object) {
  5008. var objValue = get(object, path);
  5009. return (objValue === undefined && objValue === srcValue)
  5010. ? hasIn(object, path)
  5011. : baseIsEqual(srcValue, objValue, COMPARE_PARTIAL_FLAG | COMPARE_UNORDERED_FLAG);
  5012. };
  5013. }
  5014. /**
  5015. * The base implementation of `_.merge` without support for multiple sources.
  5016. *
  5017. * @private
  5018. * @param {Object} object The destination object.
  5019. * @param {Object} source The source object.
  5020. * @param {number} srcIndex The index of `source`.
  5021. * @param {Function} [customizer] The function to customize merged values.
  5022. * @param {Object} [stack] Tracks traversed source values and their merged
  5023. * counterparts.
  5024. */
  5025. function baseMerge(object, source, srcIndex, customizer, stack) {
  5026. if (object === source) {
  5027. return;
  5028. }
  5029. baseFor(source, function(srcValue, key) {
  5030. stack || (stack = new Stack);
  5031. if (isObject(srcValue)) {
  5032. baseMergeDeep(object, source, key, srcIndex, baseMerge, customizer, stack);
  5033. }
  5034. else {
  5035. var newValue = customizer
  5036. ? customizer(safeGet(object, key), srcValue, (key + ''), object, source, stack)
  5037. : undefined;
  5038. if (newValue === undefined) {
  5039. newValue = srcValue;
  5040. }
  5041. assignMergeValue(object, key, newValue);
  5042. }
  5043. }, keysIn);
  5044. }
  5045. /**
  5046. * A specialized version of `baseMerge` for arrays and objects which performs
  5047. * deep merges and tracks traversed objects enabling objects with circular
  5048. * references to be merged.
  5049. *
  5050. * @private
  5051. * @param {Object} object The destination object.
  5052. * @param {Object} source The source object.
  5053. * @param {string} key The key of the value to merge.
  5054. * @param {number} srcIndex The index of `source`.
  5055. * @param {Function} mergeFunc The function to merge values.
  5056. * @param {Function} [customizer] The function to customize assigned values.
  5057. * @param {Object} [stack] Tracks traversed source values and their merged
  5058. * counterparts.
  5059. */
  5060. function baseMergeDeep(object, source, key, srcIndex, mergeFunc, customizer, stack) {
  5061. var objValue = safeGet(object, key),
  5062. srcValue = safeGet(source, key),
  5063. stacked = stack.get(srcValue);
  5064. if (stacked) {
  5065. assignMergeValue(object, key, stacked);
  5066. return;
  5067. }
  5068. var newValue = customizer
  5069. ? customizer(objValue, srcValue, (key + ''), object, source, stack)
  5070. : undefined;
  5071. var isCommon = newValue === undefined;
  5072. if (isCommon) {
  5073. var isArr = isArray(srcValue),
  5074. isBuff = !isArr && isBuffer(srcValue),
  5075. isTyped = !isArr && !isBuff && isTypedArray(srcValue);
  5076. newValue = srcValue;
  5077. if (isArr || isBuff || isTyped) {
  5078. if (isArray(objValue)) {
  5079. newValue = objValue;
  5080. }
  5081. else if (isArrayLikeObject(objValue)) {
  5082. newValue = copyArray(objValue);
  5083. }
  5084. else if (isBuff) {
  5085. isCommon = false;
  5086. newValue = cloneBuffer(srcValue, true);
  5087. }
  5088. else if (isTyped) {
  5089. isCommon = false;
  5090. newValue = cloneTypedArray(srcValue, true);
  5091. }
  5092. else {
  5093. newValue = [];
  5094. }
  5095. }
  5096. else if (isPlainObject(srcValue) || isArguments(srcValue)) {
  5097. newValue = objValue;
  5098. if (isArguments(objValue)) {
  5099. newValue = toPlainObject(objValue);
  5100. }
  5101. else if (!isObject(objValue) || isFunction(objValue)) {
  5102. newValue = initCloneObject(srcValue);
  5103. }
  5104. }
  5105. else {
  5106. isCommon = false;
  5107. }
  5108. }
  5109. if (isCommon) {
  5110. // Recursively merge objects and arrays (susceptible to call stack limits).
  5111. stack.set(srcValue, newValue);
  5112. mergeFunc(newValue, srcValue, srcIndex, customizer, stack);
  5113. stack['delete'](srcValue);
  5114. }
  5115. assignMergeValue(object, key, newValue);
  5116. }
  5117. /**
  5118. * The base implementation of `_.nth` which doesn't coerce arguments.
  5119. *
  5120. * @private
  5121. * @param {Array} array The array to query.
  5122. * @param {number} n The index of the element to return.
  5123. * @returns {*} Returns the nth element of `array`.
  5124. */
  5125. function baseNth(array, n) {
  5126. var length = array.length;
  5127. if (!length) {
  5128. return;
  5129. }
  5130. n += n < 0 ? length : 0;
  5131. return isIndex(n, length) ? array[n] : undefined;
  5132. }
  5133. /**
  5134. * The base implementation of `_.orderBy` without param guards.
  5135. *
  5136. * @private
  5137. * @param {Array|Object} collection The collection to iterate over.
  5138. * @param {Function[]|Object[]|string[]} iteratees The iteratees to sort by.
  5139. * @param {string[]} orders The sort orders of `iteratees`.
  5140. * @returns {Array} Returns the new sorted array.
  5141. */
  5142. function baseOrderBy(collection, iteratees, orders) {
  5143. if (iteratees.length) {
  5144. iteratees = arrayMap(iteratees, function(iteratee) {
  5145. if (isArray(iteratee)) {
  5146. return function(value) {
  5147. return baseGet(value, iteratee.length === 1 ? iteratee[0] : iteratee);
  5148. }
  5149. }
  5150. return iteratee;
  5151. });
  5152. } else {
  5153. iteratees = [identity];
  5154. }
  5155. var index = -1;
  5156. iteratees = arrayMap(iteratees, baseUnary(getIteratee()));
  5157. var result = baseMap(collection, function(value, key, collection) {
  5158. var criteria = arrayMap(iteratees, function(iteratee) {
  5159. return iteratee(value);
  5160. });
  5161. return { 'criteria': criteria, 'index': ++index, 'value': value };
  5162. });
  5163. return baseSortBy(result, function(object, other) {
  5164. return compareMultiple(object, other, orders);
  5165. });
  5166. }
  5167. /**
  5168. * The base implementation of `_.pick` without support for individual
  5169. * property identifiers.
  5170. *
  5171. * @private
  5172. * @param {Object} object The source object.
  5173. * @param {string[]} paths The property paths to pick.
  5174. * @returns {Object} Returns the new object.
  5175. */
  5176. function basePick(object, paths) {
  5177. return basePickBy(object, paths, function(value, path) {
  5178. return hasIn(object, path);
  5179. });
  5180. }
  5181. /**
  5182. * The base implementation of `_.pickBy` without support for iteratee shorthands.
  5183. *
  5184. * @private
  5185. * @param {Object} object The source object.
  5186. * @param {string[]} paths The property paths to pick.
  5187. * @param {Function} predicate The function invoked per property.
  5188. * @returns {Object} Returns the new object.
  5189. */
  5190. function basePickBy(object, paths, predicate) {
  5191. var index = -1,
  5192. length = paths.length,
  5193. result = {};
  5194. while (++index < length) {
  5195. var path = paths[index],
  5196. value = baseGet(object, path);
  5197. if (predicate(value, path)) {
  5198. baseSet(result, castPath(path, object), value);
  5199. }
  5200. }
  5201. return result;
  5202. }
  5203. /**
  5204. * A specialized version of `baseProperty` which supports deep paths.
  5205. *
  5206. * @private
  5207. * @param {Array|string} path The path of the property to get.
  5208. * @returns {Function} Returns the new accessor function.
  5209. */
  5210. function basePropertyDeep(path) {
  5211. return function(object) {
  5212. return baseGet(object, path);
  5213. };
  5214. }
  5215. /**
  5216. * The base implementation of `_.pullAllBy` without support for iteratee
  5217. * shorthands.
  5218. *
  5219. * @private
  5220. * @param {Array} array The array to modify.
  5221. * @param {Array} values The values to remove.
  5222. * @param {Function} [iteratee] The iteratee invoked per element.
  5223. * @param {Function} [comparator] The comparator invoked per element.
  5224. * @returns {Array} Returns `array`.
  5225. */
  5226. function basePullAll(array, values, iteratee, comparator) {
  5227. var indexOf = comparator ? baseIndexOfWith : baseIndexOf,
  5228. index = -1,
  5229. length = values.length,
  5230. seen = array;
  5231. if (array === values) {
  5232. values = copyArray(values);
  5233. }
  5234. if (iteratee) {
  5235. seen = arrayMap(array, baseUnary(iteratee));
  5236. }
  5237. while (++index < length) {
  5238. var fromIndex = 0,
  5239. value = values[index],
  5240. computed = iteratee ? iteratee(value) : value;
  5241. while ((fromIndex = indexOf(seen, computed, fromIndex, comparator)) > -1) {
  5242. if (seen !== array) {
  5243. splice.call(seen, fromIndex, 1);
  5244. }
  5245. splice.call(array, fromIndex, 1);
  5246. }
  5247. }
  5248. return array;
  5249. }
  5250. /**
  5251. * The base implementation of `_.pullAt` without support for individual
  5252. * indexes or capturing the removed elements.
  5253. *
  5254. * @private
  5255. * @param {Array} array The array to modify.
  5256. * @param {number[]} indexes The indexes of elements to remove.
  5257. * @returns {Array} Returns `array`.
  5258. */
  5259. function basePullAt(array, indexes) {
  5260. var length = array ? indexes.length : 0,
  5261. lastIndex = length - 1;
  5262. while (length--) {
  5263. var index = indexes[length];
  5264. if (length == lastIndex || index !== previous) {
  5265. var previous = index;
  5266. if (isIndex(index)) {
  5267. splice.call(array, index, 1);
  5268. } else {
  5269. baseUnset(array, index);
  5270. }
  5271. }
  5272. }
  5273. return array;
  5274. }
  5275. /**
  5276. * The base implementation of `_.random` without support for returning
  5277. * floating-point numbers.
  5278. *
  5279. * @private
  5280. * @param {number} lower The lower bound.
  5281. * @param {number} upper The upper bound.
  5282. * @returns {number} Returns the random number.
  5283. */
  5284. function baseRandom(lower, upper) {
  5285. return lower + nativeFloor(nativeRandom() * (upper - lower + 1));
  5286. }
  5287. /**
  5288. * The base implementation of `_.range` and `_.rangeRight` which doesn't
  5289. * coerce arguments.
  5290. *
  5291. * @private
  5292. * @param {number} start The start of the range.
  5293. * @param {number} end The end of the range.
  5294. * @param {number} step The value to increment or decrement by.
  5295. * @param {boolean} [fromRight] Specify iterating from right to left.
  5296. * @returns {Array} Returns the range of numbers.
  5297. */
  5298. function baseRange(start, end, step, fromRight) {
  5299. var index = -1,
  5300. length = nativeMax(nativeCeil((end - start) / (step || 1)), 0),
  5301. result = Array(length);
  5302. while (length--) {
  5303. result[fromRight ? length : ++index] = start;
  5304. start += step;
  5305. }
  5306. return result;
  5307. }
  5308. /**
  5309. * The base implementation of `_.repeat` which doesn't coerce arguments.
  5310. *
  5311. * @private
  5312. * @param {string} string The string to repeat.
  5313. * @param {number} n The number of times to repeat the string.
  5314. * @returns {string} Returns the repeated string.
  5315. */
  5316. function baseRepeat(string, n) {
  5317. var result = '';
  5318. if (!string || n < 1 || n > MAX_SAFE_INTEGER) {
  5319. return result;
  5320. }
  5321. // Leverage the exponentiation by squaring algorithm for a faster repeat.
  5322. // See https://en.wikipedia.org/wiki/Exponentiation_by_squaring for more details.
  5323. do {
  5324. if (n % 2) {
  5325. result += string;
  5326. }
  5327. n = nativeFloor(n / 2);
  5328. if (n) {
  5329. string += string;
  5330. }
  5331. } while (n);
  5332. return result;
  5333. }
  5334. /**
  5335. * The base implementation of `_.rest` which doesn't validate or coerce arguments.
  5336. *
  5337. * @private
  5338. * @param {Function} func The function to apply a rest parameter to.
  5339. * @param {number} [start=func.length-1] The start position of the rest parameter.
  5340. * @returns {Function} Returns the new function.
  5341. */
  5342. function baseRest(func, start) {
  5343. return setToString(overRest(func, start, identity), func + '');
  5344. }
  5345. /**
  5346. * The base implementation of `_.sample`.
  5347. *
  5348. * @private
  5349. * @param {Array|Object} collection The collection to sample.
  5350. * @returns {*} Returns the random element.
  5351. */
  5352. function baseSample(collection) {
  5353. return arraySample(values(collection));
  5354. }
  5355. /**
  5356. * The base implementation of `_.sampleSize` without param guards.
  5357. *
  5358. * @private
  5359. * @param {Array|Object} collection The collection to sample.
  5360. * @param {number} n The number of elements to sample.
  5361. * @returns {Array} Returns the random elements.
  5362. */
  5363. function baseSampleSize(collection, n) {
  5364. var array = values(collection);
  5365. return shuffleSelf(array, baseClamp(n, 0, array.length));
  5366. }
  5367. /**
  5368. * The base implementation of `_.set`.
  5369. *
  5370. * @private
  5371. * @param {Object} object The object to modify.
  5372. * @param {Array|string} path The path of the property to set.
  5373. * @param {*} value The value to set.
  5374. * @param {Function} [customizer] The function to customize path creation.
  5375. * @returns {Object} Returns `object`.
  5376. */
  5377. function baseSet(object, path, value, customizer) {
  5378. if (!isObject(object)) {
  5379. return object;
  5380. }
  5381. path = castPath(path, object);
  5382. var index = -1,
  5383. length = path.length,
  5384. lastIndex = length - 1,
  5385. nested = object;
  5386. while (nested != null && ++index < length) {
  5387. var key = toKey(path[index]),
  5388. newValue = value;
  5389. if (key === '__proto__' || key === 'constructor' || key === 'prototype') {
  5390. return object;
  5391. }
  5392. if (index != lastIndex) {
  5393. var objValue = nested[key];
  5394. newValue = customizer ? customizer(objValue, key, nested) : undefined;
  5395. if (newValue === undefined) {
  5396. newValue = isObject(objValue)
  5397. ? objValue
  5398. : (isIndex(path[index + 1]) ? [] : {});
  5399. }
  5400. }
  5401. assignValue(nested, key, newValue);
  5402. nested = nested[key];
  5403. }
  5404. return object;
  5405. }
  5406. /**
  5407. * The base implementation of `setData` without support for hot loop shorting.
  5408. *
  5409. * @private
  5410. * @param {Function} func The function to associate metadata with.
  5411. * @param {*} data The metadata.
  5412. * @returns {Function} Returns `func`.
  5413. */
  5414. var baseSetData = !metaMap ? identity : function(func, data) {
  5415. metaMap.set(func, data);
  5416. return func;
  5417. };
  5418. /**
  5419. * The base implementation of `setToString` without support for hot loop shorting.
  5420. *
  5421. * @private
  5422. * @param {Function} func The function to modify.
  5423. * @param {Function} string The `toString` result.
  5424. * @returns {Function} Returns `func`.
  5425. */
  5426. var baseSetToString = !defineProperty ? identity : function(func, string) {
  5427. return defineProperty(func, 'toString', {
  5428. 'configurable': true,
  5429. 'enumerable': false,
  5430. 'value': constant(string),
  5431. 'writable': true
  5432. });
  5433. };
  5434. /**
  5435. * The base implementation of `_.shuffle`.
  5436. *
  5437. * @private
  5438. * @param {Array|Object} collection The collection to shuffle.
  5439. * @returns {Array} Returns the new shuffled array.
  5440. */
  5441. function baseShuffle(collection) {
  5442. return shuffleSelf(values(collection));
  5443. }
  5444. /**
  5445. * The base implementation of `_.slice` without an iteratee call guard.
  5446. *
  5447. * @private
  5448. * @param {Array} array The array to slice.
  5449. * @param {number} [start=0] The start position.
  5450. * @param {number} [end=array.length] The end position.
  5451. * @returns {Array} Returns the slice of `array`.
  5452. */
  5453. function baseSlice(array, start, end) {
  5454. var index = -1,
  5455. length = array.length;
  5456. if (start < 0) {
  5457. start = -start > length ? 0 : (length + start);
  5458. }
  5459. end = end > length ? length : end;
  5460. if (end < 0) {
  5461. end += length;
  5462. }
  5463. length = start > end ? 0 : ((end - start) >>> 0);
  5464. start >>>= 0;
  5465. var result = Array(length);
  5466. while (++index < length) {
  5467. result[index] = array[index + start];
  5468. }
  5469. return result;
  5470. }
  5471. /**
  5472. * The base implementation of `_.some` without support for iteratee shorthands.
  5473. *
  5474. * @private
  5475. * @param {Array|Object} collection The collection to iterate over.
  5476. * @param {Function} predicate The function invoked per iteration.
  5477. * @returns {boolean} Returns `true` if any element passes the predicate check,
  5478. * else `false`.
  5479. */
  5480. function baseSome(collection, predicate) {
  5481. var result;
  5482. baseEach(collection, function(value, index, collection) {
  5483. result = predicate(value, index, collection);
  5484. return !result;
  5485. });
  5486. return !!result;
  5487. }
  5488. /**
  5489. * The base implementation of `_.sortedIndex` and `_.sortedLastIndex` which
  5490. * performs a binary search of `array` to determine the index at which `value`
  5491. * should be inserted into `array` in order to maintain its sort order.
  5492. *
  5493. * @private
  5494. * @param {Array} array The sorted array to inspect.
  5495. * @param {*} value The value to evaluate.
  5496. * @param {boolean} [retHighest] Specify returning the highest qualified index.
  5497. * @returns {number} Returns the index at which `value` should be inserted
  5498. * into `array`.
  5499. */
  5500. function baseSortedIndex(array, value, retHighest) {
  5501. var low = 0,
  5502. high = array == null ? low : array.length;
  5503. if (typeof value == 'number' && value === value && high <= HALF_MAX_ARRAY_LENGTH) {
  5504. while (low < high) {
  5505. var mid = (low + high) >>> 1,
  5506. computed = array[mid];
  5507. if (computed !== null && !isSymbol(computed) &&
  5508. (retHighest ? (computed <= value) : (computed < value))) {
  5509. low = mid + 1;
  5510. } else {
  5511. high = mid;
  5512. }
  5513. }
  5514. return high;
  5515. }
  5516. return baseSortedIndexBy(array, value, identity, retHighest);
  5517. }
  5518. /**
  5519. * The base implementation of `_.sortedIndexBy` and `_.sortedLastIndexBy`
  5520. * which invokes `iteratee` for `value` and each element of `array` to compute
  5521. * their sort ranking. The iteratee is invoked with one argument; (value).
  5522. *
  5523. * @private
  5524. * @param {Array} array The sorted array to inspect.
  5525. * @param {*} value The value to evaluate.
  5526. * @param {Function} iteratee The iteratee invoked per element.
  5527. * @param {boolean} [retHighest] Specify returning the highest qualified index.
  5528. * @returns {number} Returns the index at which `value` should be inserted
  5529. * into `array`.
  5530. */
  5531. function baseSortedIndexBy(array, value, iteratee, retHighest) {
  5532. var low = 0,
  5533. high = array == null ? 0 : array.length;
  5534. if (high === 0) {
  5535. return 0;
  5536. }
  5537. value = iteratee(value);
  5538. var valIsNaN = value !== value,
  5539. valIsNull = value === null,
  5540. valIsSymbol = isSymbol(value),
  5541. valIsUndefined = value === undefined;
  5542. while (low < high) {
  5543. var mid = nativeFloor((low + high) / 2),
  5544. computed = iteratee(array[mid]),
  5545. othIsDefined = computed !== undefined,
  5546. othIsNull = computed === null,
  5547. othIsReflexive = computed === computed,
  5548. othIsSymbol = isSymbol(computed);
  5549. if (valIsNaN) {
  5550. var setLow = retHighest || othIsReflexive;
  5551. } else if (valIsUndefined) {
  5552. setLow = othIsReflexive && (retHighest || othIsDefined);
  5553. } else if (valIsNull) {
  5554. setLow = othIsReflexive && othIsDefined && (retHighest || !othIsNull);
  5555. } else if (valIsSymbol) {
  5556. setLow = othIsReflexive && othIsDefined && !othIsNull && (retHighest || !othIsSymbol);
  5557. } else if (othIsNull || othIsSymbol) {
  5558. setLow = false;
  5559. } else {
  5560. setLow = retHighest ? (computed <= value) : (computed < value);
  5561. }
  5562. if (setLow) {
  5563. low = mid + 1;
  5564. } else {
  5565. high = mid;
  5566. }
  5567. }
  5568. return nativeMin(high, MAX_ARRAY_INDEX);
  5569. }
  5570. /**
  5571. * The base implementation of `_.sortedUniq` and `_.sortedUniqBy` without
  5572. * support for iteratee shorthands.
  5573. *
  5574. * @private
  5575. * @param {Array} array The array to inspect.
  5576. * @param {Function} [iteratee] The iteratee invoked per element.
  5577. * @returns {Array} Returns the new duplicate free array.
  5578. */
  5579. function baseSortedUniq(array, iteratee) {
  5580. var index = -1,
  5581. length = array.length,
  5582. resIndex = 0,
  5583. result = [];
  5584. while (++index < length) {
  5585. var value = array[index],
  5586. computed = iteratee ? iteratee(value) : value;
  5587. if (!index || !eq(computed, seen)) {
  5588. var seen = computed;
  5589. result[resIndex++] = value === 0 ? 0 : value;
  5590. }
  5591. }
  5592. return result;
  5593. }
  5594. /**
  5595. * The base implementation of `_.toNumber` which doesn't ensure correct
  5596. * conversions of binary, hexadecimal, or octal string values.
  5597. *
  5598. * @private
  5599. * @param {*} value The value to process.
  5600. * @returns {number} Returns the number.
  5601. */
  5602. function baseToNumber(value) {
  5603. if (typeof value == 'number') {
  5604. return value;
  5605. }
  5606. if (isSymbol(value)) {
  5607. return NAN;
  5608. }
  5609. return +value;
  5610. }
  5611. /**
  5612. * The base implementation of `_.toString` which doesn't convert nullish
  5613. * values to empty strings.
  5614. *
  5615. * @private
  5616. * @param {*} value The value to process.
  5617. * @returns {string} Returns the string.
  5618. */
  5619. function baseToString(value) {
  5620. // Exit early for strings to avoid a performance hit in some environments.
  5621. if (typeof value == 'string') {
  5622. return value;
  5623. }
  5624. if (isArray(value)) {
  5625. // Recursively convert values (susceptible to call stack limits).
  5626. return arrayMap(value, baseToString) + '';
  5627. }
  5628. if (isSymbol(value)) {
  5629. return symbolToString ? symbolToString.call(value) : '';
  5630. }
  5631. var result = (value + '');
  5632. return (result == '0' && (1 / value) == -INFINITY) ? '-0' : result;
  5633. }
  5634. /**
  5635. * The base implementation of `_.uniqBy` without support for iteratee shorthands.
  5636. *
  5637. * @private
  5638. * @param {Array} array The array to inspect.
  5639. * @param {Function} [iteratee] The iteratee invoked per element.
  5640. * @param {Function} [comparator] The comparator invoked per element.
  5641. * @returns {Array} Returns the new duplicate free array.
  5642. */
  5643. function baseUniq(array, iteratee, comparator) {
  5644. var index = -1,
  5645. includes = arrayIncludes,
  5646. length = array.length,
  5647. isCommon = true,
  5648. result = [],
  5649. seen = result;
  5650. if (comparator) {
  5651. isCommon = false;
  5652. includes = arrayIncludesWith;
  5653. }
  5654. else if (length >= LARGE_ARRAY_SIZE) {
  5655. var set = iteratee ? null : createSet(array);
  5656. if (set) {
  5657. return setToArray(set);
  5658. }
  5659. isCommon = false;
  5660. includes = cacheHas;
  5661. seen = new SetCache;
  5662. }
  5663. else {
  5664. seen = iteratee ? [] : result;
  5665. }
  5666. outer:
  5667. while (++index < length) {
  5668. var value = array[index],
  5669. computed = iteratee ? iteratee(value) : value;
  5670. value = (comparator || value !== 0) ? value : 0;
  5671. if (isCommon && computed === computed) {
  5672. var seenIndex = seen.length;
  5673. while (seenIndex--) {
  5674. if (seen[seenIndex] === computed) {
  5675. continue outer;
  5676. }
  5677. }
  5678. if (iteratee) {
  5679. seen.push(computed);
  5680. }
  5681. result.push(value);
  5682. }
  5683. else if (!includes(seen, computed, comparator)) {
  5684. if (seen !== result) {
  5685. seen.push(computed);
  5686. }
  5687. result.push(value);
  5688. }
  5689. }
  5690. return result;
  5691. }
  5692. /**
  5693. * The base implementation of `_.unset`.
  5694. *
  5695. * @private
  5696. * @param {Object} object The object to modify.
  5697. * @param {Array|string} path The property path to unset.
  5698. * @returns {boolean} Returns `true` if the property is deleted, else `false`.
  5699. */
  5700. function baseUnset(object, path) {
  5701. path = castPath(path, object);
  5702. object = parent(object, path);
  5703. return object == null || delete object[toKey(last(path))];
  5704. }
  5705. /**
  5706. * The base implementation of `_.update`.
  5707. *
  5708. * @private
  5709. * @param {Object} object The object to modify.
  5710. * @param {Array|string} path The path of the property to update.
  5711. * @param {Function} updater The function to produce the updated value.
  5712. * @param {Function} [customizer] The function to customize path creation.
  5713. * @returns {Object} Returns `object`.
  5714. */
  5715. function baseUpdate(object, path, updater, customizer) {
  5716. return baseSet(object, path, updater(baseGet(object, path)), customizer);
  5717. }
  5718. /**
  5719. * The base implementation of methods like `_.dropWhile` and `_.takeWhile`
  5720. * without support for iteratee shorthands.
  5721. *
  5722. * @private
  5723. * @param {Array} array The array to query.
  5724. * @param {Function} predicate The function invoked per iteration.
  5725. * @param {boolean} [isDrop] Specify dropping elements instead of taking them.
  5726. * @param {boolean} [fromRight] Specify iterating from right to left.
  5727. * @returns {Array} Returns the slice of `array`.
  5728. */
  5729. function baseWhile(array, predicate, isDrop, fromRight) {
  5730. var length = array.length,
  5731. index = fromRight ? length : -1;
  5732. while ((fromRight ? index-- : ++index < length) &&
  5733. predicate(array[index], index, array)) {}
  5734. return isDrop
  5735. ? baseSlice(array, (fromRight ? 0 : index), (fromRight ? index + 1 : length))
  5736. : baseSlice(array, (fromRight ? index + 1 : 0), (fromRight ? length : index));
  5737. }
  5738. /**
  5739. * The base implementation of `wrapperValue` which returns the result of
  5740. * performing a sequence of actions on the unwrapped `value`, where each
  5741. * successive action is supplied the return value of the previous.
  5742. *
  5743. * @private
  5744. * @param {*} value The unwrapped value.
  5745. * @param {Array} actions Actions to perform to resolve the unwrapped value.
  5746. * @returns {*} Returns the resolved value.
  5747. */
  5748. function baseWrapperValue(value, actions) {
  5749. var result = value;
  5750. if (result instanceof LazyWrapper) {
  5751. result = result.value();
  5752. }
  5753. return arrayReduce(actions, function(result, action) {
  5754. return action.func.apply(action.thisArg, arrayPush([result], action.args));
  5755. }, result);
  5756. }
  5757. /**
  5758. * The base implementation of methods like `_.xor`, without support for
  5759. * iteratee shorthands, that accepts an array of arrays to inspect.
  5760. *
  5761. * @private
  5762. * @param {Array} arrays The arrays to inspect.
  5763. * @param {Function} [iteratee] The iteratee invoked per element.
  5764. * @param {Function} [comparator] The comparator invoked per element.
  5765. * @returns {Array} Returns the new array of values.
  5766. */
  5767. function baseXor(arrays, iteratee, comparator) {
  5768. var length = arrays.length;
  5769. if (length < 2) {
  5770. return length ? baseUniq(arrays[0]) : [];
  5771. }
  5772. var index = -1,
  5773. result = Array(length);
  5774. while (++index < length) {
  5775. var array = arrays[index],
  5776. othIndex = -1;
  5777. while (++othIndex < length) {
  5778. if (othIndex != index) {
  5779. result[index] = baseDifference(result[index] || array, arrays[othIndex], iteratee, comparator);
  5780. }
  5781. }
  5782. }
  5783. return baseUniq(baseFlatten(result, 1), iteratee, comparator);
  5784. }
  5785. /**
  5786. * This base implementation of `_.zipObject` which assigns values using `assignFunc`.
  5787. *
  5788. * @private
  5789. * @param {Array} props The property identifiers.
  5790. * @param {Array} values The property values.
  5791. * @param {Function} assignFunc The function to assign values.
  5792. * @returns {Object} Returns the new object.
  5793. */
  5794. function baseZipObject(props, values, assignFunc) {
  5795. var index = -1,
  5796. length = props.length,
  5797. valsLength = values.length,
  5798. result = {};
  5799. while (++index < length) {
  5800. var value = index < valsLength ? values[index] : undefined;
  5801. assignFunc(result, props[index], value);
  5802. }
  5803. return result;
  5804. }
  5805. /**
  5806. * Casts `value` to an empty array if it's not an array like object.
  5807. *
  5808. * @private
  5809. * @param {*} value The value to inspect.
  5810. * @returns {Array|Object} Returns the cast array-like object.
  5811. */
  5812. function castArrayLikeObject(value) {
  5813. return isArrayLikeObject(value) ? value : [];
  5814. }
  5815. /**
  5816. * Casts `value` to `identity` if it's not a function.
  5817. *
  5818. * @private
  5819. * @param {*} value The value to inspect.
  5820. * @returns {Function} Returns cast function.
  5821. */
  5822. function castFunction(value) {
  5823. return typeof value == 'function' ? value : identity;
  5824. }
  5825. /**
  5826. * Casts `value` to a path array if it's not one.
  5827. *
  5828. * @private
  5829. * @param {*} value The value to inspect.
  5830. * @param {Object} [object] The object to query keys on.
  5831. * @returns {Array} Returns the cast property path array.
  5832. */
  5833. function castPath(value, object) {
  5834. if (isArray(value)) {
  5835. return value;
  5836. }
  5837. return isKey(value, object) ? [value] : stringToPath(toString(value));
  5838. }
  5839. /**
  5840. * A `baseRest` alias which can be replaced with `identity` by module
  5841. * replacement plugins.
  5842. *
  5843. * @private
  5844. * @type {Function}
  5845. * @param {Function} func The function to apply a rest parameter to.
  5846. * @returns {Function} Returns the new function.
  5847. */
  5848. var castRest = baseRest;
  5849. /**
  5850. * Casts `array` to a slice if it's needed.
  5851. *
  5852. * @private
  5853. * @param {Array} array The array to inspect.
  5854. * @param {number} start The start position.
  5855. * @param {number} [end=array.length] The end position.
  5856. * @returns {Array} Returns the cast slice.
  5857. */
  5858. function castSlice(array, start, end) {
  5859. var length = array.length;
  5860. end = end === undefined ? length : end;
  5861. return (!start && end >= length) ? array : baseSlice(array, start, end);
  5862. }
  5863. /**
  5864. * A simple wrapper around the global [`clearTimeout`](https://mdn.io/clearTimeout).
  5865. *
  5866. * @private
  5867. * @param {number|Object} id The timer id or timeout object of the timer to clear.
  5868. */
  5869. var clearTimeout = ctxClearTimeout || function(id) {
  5870. return root.clearTimeout(id);
  5871. };
  5872. /**
  5873. * Creates a clone of `buffer`.
  5874. *
  5875. * @private
  5876. * @param {Buffer} buffer The buffer to clone.
  5877. * @param {boolean} [isDeep] Specify a deep clone.
  5878. * @returns {Buffer} Returns the cloned buffer.
  5879. */
  5880. function cloneBuffer(buffer, isDeep) {
  5881. if (isDeep) {
  5882. return buffer.slice();
  5883. }
  5884. var length = buffer.length,
  5885. result = allocUnsafe ? allocUnsafe(length) : new buffer.constructor(length);
  5886. buffer.copy(result);
  5887. return result;
  5888. }
  5889. /**
  5890. * Creates a clone of `arrayBuffer`.
  5891. *
  5892. * @private
  5893. * @param {ArrayBuffer} arrayBuffer The array buffer to clone.
  5894. * @returns {ArrayBuffer} Returns the cloned array buffer.
  5895. */
  5896. function cloneArrayBuffer(arrayBuffer) {
  5897. var result = new arrayBuffer.constructor(arrayBuffer.byteLength);
  5898. new Uint8Array(result).set(new Uint8Array(arrayBuffer));
  5899. return result;
  5900. }
  5901. /**
  5902. * Creates a clone of `dataView`.
  5903. *
  5904. * @private
  5905. * @param {Object} dataView The data view to clone.
  5906. * @param {boolean} [isDeep] Specify a deep clone.
  5907. * @returns {Object} Returns the cloned data view.
  5908. */
  5909. function cloneDataView(dataView, isDeep) {
  5910. var buffer = isDeep ? cloneArrayBuffer(dataView.buffer) : dataView.buffer;
  5911. return new dataView.constructor(buffer, dataView.byteOffset, dataView.byteLength);
  5912. }
  5913. /**
  5914. * Creates a clone of `regexp`.
  5915. *
  5916. * @private
  5917. * @param {Object} regexp The regexp to clone.
  5918. * @returns {Object} Returns the cloned regexp.
  5919. */
  5920. function cloneRegExp(regexp) {
  5921. var result = new regexp.constructor(regexp.source, reFlags.exec(regexp));
  5922. result.lastIndex = regexp.lastIndex;
  5923. return result;
  5924. }
  5925. /**
  5926. * Creates a clone of the `symbol` object.
  5927. *
  5928. * @private
  5929. * @param {Object} symbol The symbol object to clone.
  5930. * @returns {Object} Returns the cloned symbol object.
  5931. */
  5932. function cloneSymbol(symbol) {
  5933. return symbolValueOf ? Object(symbolValueOf.call(symbol)) : {};
  5934. }
  5935. /**
  5936. * Creates a clone of `typedArray`.
  5937. *
  5938. * @private
  5939. * @param {Object} typedArray The typed array to clone.
  5940. * @param {boolean} [isDeep] Specify a deep clone.
  5941. * @returns {Object} Returns the cloned typed array.
  5942. */
  5943. function cloneTypedArray(typedArray, isDeep) {
  5944. var buffer = isDeep ? cloneArrayBuffer(typedArray.buffer) : typedArray.buffer;
  5945. return new typedArray.constructor(buffer, typedArray.byteOffset, typedArray.length);
  5946. }
  5947. /**
  5948. * Compares values to sort them in ascending order.
  5949. *
  5950. * @private
  5951. * @param {*} value The value to compare.
  5952. * @param {*} other The other value to compare.
  5953. * @returns {number} Returns the sort order indicator for `value`.
  5954. */
  5955. function compareAscending(value, other) {
  5956. if (value !== other) {
  5957. var valIsDefined = value !== undefined,
  5958. valIsNull = value === null,
  5959. valIsReflexive = value === value,
  5960. valIsSymbol = isSymbol(value);
  5961. var othIsDefined = other !== undefined,
  5962. othIsNull = other === null,
  5963. othIsReflexive = other === other,
  5964. othIsSymbol = isSymbol(other);
  5965. if ((!othIsNull && !othIsSymbol && !valIsSymbol && value > other) ||
  5966. (valIsSymbol && othIsDefined && othIsReflexive && !othIsNull && !othIsSymbol) ||
  5967. (valIsNull && othIsDefined && othIsReflexive) ||
  5968. (!valIsDefined && othIsReflexive) ||
  5969. !valIsReflexive) {
  5970. return 1;
  5971. }
  5972. if ((!valIsNull && !valIsSymbol && !othIsSymbol && value < other) ||
  5973. (othIsSymbol && valIsDefined && valIsReflexive && !valIsNull && !valIsSymbol) ||
  5974. (othIsNull && valIsDefined && valIsReflexive) ||
  5975. (!othIsDefined && valIsReflexive) ||
  5976. !othIsReflexive) {
  5977. return -1;
  5978. }
  5979. }
  5980. return 0;
  5981. }
  5982. /**
  5983. * Used by `_.orderBy` to compare multiple properties of a value to another
  5984. * and stable sort them.
  5985. *
  5986. * If `orders` is unspecified, all values are sorted in ascending order. Otherwise,
  5987. * specify an order of "desc" for descending or "asc" for ascending sort order
  5988. * of corresponding values.
  5989. *
  5990. * @private
  5991. * @param {Object} object The object to compare.
  5992. * @param {Object} other The other object to compare.
  5993. * @param {boolean[]|string[]} orders The order to sort by for each property.
  5994. * @returns {number} Returns the sort order indicator for `object`.
  5995. */
  5996. function compareMultiple(object, other, orders) {
  5997. var index = -1,
  5998. objCriteria = object.criteria,
  5999. othCriteria = other.criteria,
  6000. length = objCriteria.length,
  6001. ordersLength = orders.length;
  6002. while (++index < length) {
  6003. var result = compareAscending(objCriteria[index], othCriteria[index]);
  6004. if (result) {
  6005. if (index >= ordersLength) {
  6006. return result;
  6007. }
  6008. var order = orders[index];
  6009. return result * (order == 'desc' ? -1 : 1);
  6010. }
  6011. }
  6012. // Fixes an `Array#sort` bug in the JS engine embedded in Adobe applications
  6013. // that causes it, under certain circumstances, to provide the same value for
  6014. // `object` and `other`. See https://github.com/jashkenas/underscore/pull/1247
  6015. // for more details.
  6016. //
  6017. // This also ensures a stable sort in V8 and other engines.
  6018. // See https://bugs.chromium.org/p/v8/issues/detail?id=90 for more details.
  6019. return object.index - other.index;
  6020. }
  6021. /**
  6022. * Creates an array that is the composition of partially applied arguments,
  6023. * placeholders, and provided arguments into a single array of arguments.
  6024. *
  6025. * @private
  6026. * @param {Array} args The provided arguments.
  6027. * @param {Array} partials The arguments to prepend to those provided.
  6028. * @param {Array} holders The `partials` placeholder indexes.
  6029. * @params {boolean} [isCurried] Specify composing for a curried function.
  6030. * @returns {Array} Returns the new array of composed arguments.
  6031. */
  6032. function composeArgs(args, partials, holders, isCurried) {
  6033. var argsIndex = -1,
  6034. argsLength = args.length,
  6035. holdersLength = holders.length,
  6036. leftIndex = -1,
  6037. leftLength = partials.length,
  6038. rangeLength = nativeMax(argsLength - holdersLength, 0),
  6039. result = Array(leftLength + rangeLength),
  6040. isUncurried = !isCurried;
  6041. while (++leftIndex < leftLength) {
  6042. result[leftIndex] = partials[leftIndex];
  6043. }
  6044. while (++argsIndex < holdersLength) {
  6045. if (isUncurried || argsIndex < argsLength) {
  6046. result[holders[argsIndex]] = args[argsIndex];
  6047. }
  6048. }
  6049. while (rangeLength--) {
  6050. result[leftIndex++] = args[argsIndex++];
  6051. }
  6052. return result;
  6053. }
  6054. /**
  6055. * This function is like `composeArgs` except that the arguments composition
  6056. * is tailored for `_.partialRight`.
  6057. *
  6058. * @private
  6059. * @param {Array} args The provided arguments.
  6060. * @param {Array} partials The arguments to append to those provided.
  6061. * @param {Array} holders The `partials` placeholder indexes.
  6062. * @params {boolean} [isCurried] Specify composing for a curried function.
  6063. * @returns {Array} Returns the new array of composed arguments.
  6064. */
  6065. function composeArgsRight(args, partials, holders, isCurried) {
  6066. var argsIndex = -1,
  6067. argsLength = args.length,
  6068. holdersIndex = -1,
  6069. holdersLength = holders.length,
  6070. rightIndex = -1,
  6071. rightLength = partials.length,
  6072. rangeLength = nativeMax(argsLength - holdersLength, 0),
  6073. result = Array(rangeLength + rightLength),
  6074. isUncurried = !isCurried;
  6075. while (++argsIndex < rangeLength) {
  6076. result[argsIndex] = args[argsIndex];
  6077. }
  6078. var offset = argsIndex;
  6079. while (++rightIndex < rightLength) {
  6080. result[offset + rightIndex] = partials[rightIndex];
  6081. }
  6082. while (++holdersIndex < holdersLength) {
  6083. if (isUncurried || argsIndex < argsLength) {
  6084. result[offset + holders[holdersIndex]] = args[argsIndex++];
  6085. }
  6086. }
  6087. return result;
  6088. }
  6089. /**
  6090. * Copies the values of `source` to `array`.
  6091. *
  6092. * @private
  6093. * @param {Array} source The array to copy values from.
  6094. * @param {Array} [array=[]] The array to copy values to.
  6095. * @returns {Array} Returns `array`.
  6096. */
  6097. function copyArray(source, array) {
  6098. var index = -1,
  6099. length = source.length;
  6100. array || (array = Array(length));
  6101. while (++index < length) {
  6102. array[index] = source[index];
  6103. }
  6104. return array;
  6105. }
  6106. /**
  6107. * Copies properties of `source` to `object`.
  6108. *
  6109. * @private
  6110. * @param {Object} source The object to copy properties from.
  6111. * @param {Array} props The property identifiers to copy.
  6112. * @param {Object} [object={}] The object to copy properties to.
  6113. * @param {Function} [customizer] The function to customize copied values.
  6114. * @returns {Object} Returns `object`.
  6115. */
  6116. function copyObject(source, props, object, customizer) {
  6117. var isNew = !object;
  6118. object || (object = {});
  6119. var index = -1,
  6120. length = props.length;
  6121. while (++index < length) {
  6122. var key = props[index];
  6123. var newValue = customizer
  6124. ? customizer(object[key], source[key], key, object, source)
  6125. : undefined;
  6126. if (newValue === undefined) {
  6127. newValue = source[key];
  6128. }
  6129. if (isNew) {
  6130. baseAssignValue(object, key, newValue);
  6131. } else {
  6132. assignValue(object, key, newValue);
  6133. }
  6134. }
  6135. return object;
  6136. }
  6137. /**
  6138. * Copies own symbols of `source` to `object`.
  6139. *
  6140. * @private
  6141. * @param {Object} source The object to copy symbols from.
  6142. * @param {Object} [object={}] The object to copy symbols to.
  6143. * @returns {Object} Returns `object`.
  6144. */
  6145. function copySymbols(source, object) {
  6146. return copyObject(source, getSymbols(source), object);
  6147. }
  6148. /**
  6149. * Copies own and inherited symbols of `source` to `object`.
  6150. *
  6151. * @private
  6152. * @param {Object} source The object to copy symbols from.
  6153. * @param {Object} [object={}] The object to copy symbols to.
  6154. * @returns {Object} Returns `object`.
  6155. */
  6156. function copySymbolsIn(source, object) {
  6157. return copyObject(source, getSymbolsIn(source), object);
  6158. }
  6159. /**
  6160. * Creates a function like `_.groupBy`.
  6161. *
  6162. * @private
  6163. * @param {Function} setter The function to set accumulator values.
  6164. * @param {Function} [initializer] The accumulator object initializer.
  6165. * @returns {Function} Returns the new aggregator function.
  6166. */
  6167. function createAggregator(setter, initializer) {
  6168. return function(collection, iteratee) {
  6169. var func = isArray(collection) ? arrayAggregator : baseAggregator,
  6170. accumulator = initializer ? initializer() : {};
  6171. return func(collection, setter, getIteratee(iteratee, 2), accumulator);
  6172. };
  6173. }
  6174. /**
  6175. * Creates a function like `_.assign`.
  6176. *
  6177. * @private
  6178. * @param {Function} assigner The function to assign values.
  6179. * @returns {Function} Returns the new assigner function.
  6180. */
  6181. function createAssigner(assigner) {
  6182. return baseRest(function(object, sources) {
  6183. var index = -1,
  6184. length = sources.length,
  6185. customizer = length > 1 ? sources[length - 1] : undefined,
  6186. guard = length > 2 ? sources[2] : undefined;
  6187. customizer = (assigner.length > 3 && typeof customizer == 'function')
  6188. ? (length--, customizer)
  6189. : undefined;
  6190. if (guard && isIterateeCall(sources[0], sources[1], guard)) {
  6191. customizer = length < 3 ? undefined : customizer;
  6192. length = 1;
  6193. }
  6194. object = Object(object);
  6195. while (++index < length) {
  6196. var source = sources[index];
  6197. if (source) {
  6198. assigner(object, source, index, customizer);
  6199. }
  6200. }
  6201. return object;
  6202. });
  6203. }
  6204. /**
  6205. * Creates a `baseEach` or `baseEachRight` function.
  6206. *
  6207. * @private
  6208. * @param {Function} eachFunc The function to iterate over a collection.
  6209. * @param {boolean} [fromRight] Specify iterating from right to left.
  6210. * @returns {Function} Returns the new base function.
  6211. */
  6212. function createBaseEach(eachFunc, fromRight) {
  6213. return function(collection, iteratee) {
  6214. if (collection == null) {
  6215. return collection;
  6216. }
  6217. if (!isArrayLike(collection)) {
  6218. return eachFunc(collection, iteratee);
  6219. }
  6220. var length = collection.length,
  6221. index = fromRight ? length : -1,
  6222. iterable = Object(collection);
  6223. while ((fromRight ? index-- : ++index < length)) {
  6224. if (iteratee(iterable[index], index, iterable) === false) {
  6225. break;
  6226. }
  6227. }
  6228. return collection;
  6229. };
  6230. }
  6231. /**
  6232. * Creates a base function for methods like `_.forIn` and `_.forOwn`.
  6233. *
  6234. * @private
  6235. * @param {boolean} [fromRight] Specify iterating from right to left.
  6236. * @returns {Function} Returns the new base function.
  6237. */
  6238. function createBaseFor(fromRight) {
  6239. return function(object, iteratee, keysFunc) {
  6240. var index = -1,
  6241. iterable = Object(object),
  6242. props = keysFunc(object),
  6243. length = props.length;
  6244. while (length--) {
  6245. var key = props[fromRight ? length : ++index];
  6246. if (iteratee(iterable[key], key, iterable) === false) {
  6247. break;
  6248. }
  6249. }
  6250. return object;
  6251. };
  6252. }
  6253. /**
  6254. * Creates a function that wraps `func` to invoke it with the optional `this`
  6255. * binding of `thisArg`.
  6256. *
  6257. * @private
  6258. * @param {Function} func The function to wrap.
  6259. * @param {number} bitmask The bitmask flags. See `createWrap` for more details.
  6260. * @param {*} [thisArg] The `this` binding of `func`.
  6261. * @returns {Function} Returns the new wrapped function.
  6262. */
  6263. function createBind(func, bitmask, thisArg) {
  6264. var isBind = bitmask & WRAP_BIND_FLAG,
  6265. Ctor = createCtor(func);
  6266. function wrapper() {
  6267. var fn = (this && this !== root && this instanceof wrapper) ? Ctor : func;
  6268. return fn.apply(isBind ? thisArg : this, arguments);
  6269. }
  6270. return wrapper;
  6271. }
  6272. /**
  6273. * Creates a function like `_.lowerFirst`.
  6274. *
  6275. * @private
  6276. * @param {string} methodName The name of the `String` case method to use.
  6277. * @returns {Function} Returns the new case function.
  6278. */
  6279. function createCaseFirst(methodName) {
  6280. return function(string) {
  6281. string = toString(string);
  6282. var strSymbols = hasUnicode(string)
  6283. ? stringToArray(string)
  6284. : undefined;
  6285. var chr = strSymbols
  6286. ? strSymbols[0]
  6287. : string.charAt(0);
  6288. var trailing = strSymbols
  6289. ? castSlice(strSymbols, 1).join('')
  6290. : string.slice(1);
  6291. return chr[methodName]() + trailing;
  6292. };
  6293. }
  6294. /**
  6295. * Creates a function like `_.camelCase`.
  6296. *
  6297. * @private
  6298. * @param {Function} callback The function to combine each word.
  6299. * @returns {Function} Returns the new compounder function.
  6300. */
  6301. function createCompounder(callback) {
  6302. return function(string) {
  6303. return arrayReduce(words(deburr(string).replace(reApos, '')), callback, '');
  6304. };
  6305. }
  6306. /**
  6307. * Creates a function that produces an instance of `Ctor` regardless of
  6308. * whether it was invoked as part of a `new` expression or by `call` or `apply`.
  6309. *
  6310. * @private
  6311. * @param {Function} Ctor The constructor to wrap.
  6312. * @returns {Function} Returns the new wrapped function.
  6313. */
  6314. function createCtor(Ctor) {
  6315. return function() {
  6316. // Use a `switch` statement to work with class constructors. See
  6317. // http://ecma-international.org/ecma-262/7.0/#sec-ecmascript-function-objects-call-thisargument-argumentslist
  6318. // for more details.
  6319. var args = arguments;
  6320. switch (args.length) {
  6321. case 0: return new Ctor;
  6322. case 1: return new Ctor(args[0]);
  6323. case 2: return new Ctor(args[0], args[1]);
  6324. case 3: return new Ctor(args[0], args[1], args[2]);
  6325. case 4: return new Ctor(args[0], args[1], args[2], args[3]);
  6326. case 5: return new Ctor(args[0], args[1], args[2], args[3], args[4]);
  6327. case 6: return new Ctor(args[0], args[1], args[2], args[3], args[4], args[5]);
  6328. case 7: return new Ctor(args[0], args[1], args[2], args[3], args[4], args[5], args[6]);
  6329. }
  6330. var thisBinding = baseCreate(Ctor.prototype),
  6331. result = Ctor.apply(thisBinding, args);
  6332. // Mimic the constructor's `return` behavior.
  6333. // See https://es5.github.io/#x13.2.2 for more details.
  6334. return isObject(result) ? result : thisBinding;
  6335. };
  6336. }
  6337. /**
  6338. * Creates a function that wraps `func` to enable currying.
  6339. *
  6340. * @private
  6341. * @param {Function} func The function to wrap.
  6342. * @param {number} bitmask The bitmask flags. See `createWrap` for more details.
  6343. * @param {number} arity The arity of `func`.
  6344. * @returns {Function} Returns the new wrapped function.
  6345. */
  6346. function createCurry(func, bitmask, arity) {
  6347. var Ctor = createCtor(func);
  6348. function wrapper() {
  6349. var length = arguments.length,
  6350. args = Array(length),
  6351. index = length,
  6352. placeholder = getHolder(wrapper);
  6353. while (index--) {
  6354. args[index] = arguments[index];
  6355. }
  6356. var holders = (length < 3 && args[0] !== placeholder && args[length - 1] !== placeholder)
  6357. ? []
  6358. : replaceHolders(args, placeholder);
  6359. length -= holders.length;
  6360. if (length < arity) {
  6361. return createRecurry(
  6362. func, bitmask, createHybrid, wrapper.placeholder, undefined,
  6363. args, holders, undefined, undefined, arity - length);
  6364. }
  6365. var fn = (this && this !== root && this instanceof wrapper) ? Ctor : func;
  6366. return apply(fn, this, args);
  6367. }
  6368. return wrapper;
  6369. }
  6370. /**
  6371. * Creates a `_.find` or `_.findLast` function.
  6372. *
  6373. * @private
  6374. * @param {Function} findIndexFunc The function to find the collection index.
  6375. * @returns {Function} Returns the new find function.
  6376. */
  6377. function createFind(findIndexFunc) {
  6378. return function(collection, predicate, fromIndex) {
  6379. var iterable = Object(collection);
  6380. if (!isArrayLike(collection)) {
  6381. var iteratee = getIteratee(predicate, 3);
  6382. collection = keys(collection);
  6383. predicate = function(key) { return iteratee(iterable[key], key, iterable); };
  6384. }
  6385. var index = findIndexFunc(collection, predicate, fromIndex);
  6386. return index > -1 ? iterable[iteratee ? collection[index] : index] : undefined;
  6387. };
  6388. }
  6389. /**
  6390. * Creates a `_.flow` or `_.flowRight` function.
  6391. *
  6392. * @private
  6393. * @param {boolean} [fromRight] Specify iterating from right to left.
  6394. * @returns {Function} Returns the new flow function.
  6395. */
  6396. function createFlow(fromRight) {
  6397. return flatRest(function(funcs) {
  6398. var length = funcs.length,
  6399. index = length,
  6400. prereq = LodashWrapper.prototype.thru;
  6401. if (fromRight) {
  6402. funcs.reverse();
  6403. }
  6404. while (index--) {
  6405. var func = funcs[index];
  6406. if (typeof func != 'function') {
  6407. throw new TypeError(FUNC_ERROR_TEXT);
  6408. }
  6409. if (prereq && !wrapper && getFuncName(func) == 'wrapper') {
  6410. var wrapper = new LodashWrapper([], true);
  6411. }
  6412. }
  6413. index = wrapper ? index : length;
  6414. while (++index < length) {
  6415. func = funcs[index];
  6416. var funcName = getFuncName(func),
  6417. data = funcName == 'wrapper' ? getData(func) : undefined;
  6418. if (data && isLaziable(data[0]) &&
  6419. data[1] == (WRAP_ARY_FLAG | WRAP_CURRY_FLAG | WRAP_PARTIAL_FLAG | WRAP_REARG_FLAG) &&
  6420. !data[4].length && data[9] == 1
  6421. ) {
  6422. wrapper = wrapper[getFuncName(data[0])].apply(wrapper, data[3]);
  6423. } else {
  6424. wrapper = (func.length == 1 && isLaziable(func))
  6425. ? wrapper[funcName]()
  6426. : wrapper.thru(func);
  6427. }
  6428. }
  6429. return function() {
  6430. var args = arguments,
  6431. value = args[0];
  6432. if (wrapper && args.length == 1 && isArray(value)) {
  6433. return wrapper.plant(value).value();
  6434. }
  6435. var index = 0,
  6436. result = length ? funcs[index].apply(this, args) : value;
  6437. while (++index < length) {
  6438. result = funcs[index].call(this, result);
  6439. }
  6440. return result;
  6441. };
  6442. });
  6443. }
  6444. /**
  6445. * Creates a function that wraps `func` to invoke it with optional `this`
  6446. * binding of `thisArg`, partial application, and currying.
  6447. *
  6448. * @private
  6449. * @param {Function|string} func The function or method name to wrap.
  6450. * @param {number} bitmask The bitmask flags. See `createWrap` for more details.
  6451. * @param {*} [thisArg] The `this` binding of `func`.
  6452. * @param {Array} [partials] The arguments to prepend to those provided to
  6453. * the new function.
  6454. * @param {Array} [holders] The `partials` placeholder indexes.
  6455. * @param {Array} [partialsRight] The arguments to append to those provided
  6456. * to the new function.
  6457. * @param {Array} [holdersRight] The `partialsRight` placeholder indexes.
  6458. * @param {Array} [argPos] The argument positions of the new function.
  6459. * @param {number} [ary] The arity cap of `func`.
  6460. * @param {number} [arity] The arity of `func`.
  6461. * @returns {Function} Returns the new wrapped function.
  6462. */
  6463. function createHybrid(func, bitmask, thisArg, partials, holders, partialsRight, holdersRight, argPos, ary, arity) {
  6464. var isAry = bitmask & WRAP_ARY_FLAG,
  6465. isBind = bitmask & WRAP_BIND_FLAG,
  6466. isBindKey = bitmask & WRAP_BIND_KEY_FLAG,
  6467. isCurried = bitmask & (WRAP_CURRY_FLAG | WRAP_CURRY_RIGHT_FLAG),
  6468. isFlip = bitmask & WRAP_FLIP_FLAG,
  6469. Ctor = isBindKey ? undefined : createCtor(func);
  6470. function wrapper() {
  6471. var length = arguments.length,
  6472. args = Array(length),
  6473. index = length;
  6474. while (index--) {
  6475. args[index] = arguments[index];
  6476. }
  6477. if (isCurried) {
  6478. var placeholder = getHolder(wrapper),
  6479. holdersCount = countHolders(args, placeholder);
  6480. }
  6481. if (partials) {
  6482. args = composeArgs(args, partials, holders, isCurried);
  6483. }
  6484. if (partialsRight) {
  6485. args = composeArgsRight(args, partialsRight, holdersRight, isCurried);
  6486. }
  6487. length -= holdersCount;
  6488. if (isCurried && length < arity) {
  6489. var newHolders = replaceHolders(args, placeholder);
  6490. return createRecurry(
  6491. func, bitmask, createHybrid, wrapper.placeholder, thisArg,
  6492. args, newHolders, argPos, ary, arity - length
  6493. );
  6494. }
  6495. var thisBinding = isBind ? thisArg : this,
  6496. fn = isBindKey ? thisBinding[func] : func;
  6497. length = args.length;
  6498. if (argPos) {
  6499. args = reorder(args, argPos);
  6500. } else if (isFlip && length > 1) {
  6501. args.reverse();
  6502. }
  6503. if (isAry && ary < length) {
  6504. args.length = ary;
  6505. }
  6506. if (this && this !== root && this instanceof wrapper) {
  6507. fn = Ctor || createCtor(fn);
  6508. }
  6509. return fn.apply(thisBinding, args);
  6510. }
  6511. return wrapper;
  6512. }
  6513. /**
  6514. * Creates a function like `_.invertBy`.
  6515. *
  6516. * @private
  6517. * @param {Function} setter The function to set accumulator values.
  6518. * @param {Function} toIteratee The function to resolve iteratees.
  6519. * @returns {Function} Returns the new inverter function.
  6520. */
  6521. function createInverter(setter, toIteratee) {
  6522. return function(object, iteratee) {
  6523. return baseInverter(object, setter, toIteratee(iteratee), {});
  6524. };
  6525. }
  6526. /**
  6527. * Creates a function that performs a mathematical operation on two values.
  6528. *
  6529. * @private
  6530. * @param {Function} operator The function to perform the operation.
  6531. * @param {number} [defaultValue] The value used for `undefined` arguments.
  6532. * @returns {Function} Returns the new mathematical operation function.
  6533. */
  6534. function createMathOperation(operator, defaultValue) {
  6535. return function(value, other) {
  6536. var result;
  6537. if (value === undefined && other === undefined) {
  6538. return defaultValue;
  6539. }
  6540. if (value !== undefined) {
  6541. result = value;
  6542. }
  6543. if (other !== undefined) {
  6544. if (result === undefined) {
  6545. return other;
  6546. }
  6547. if (typeof value == 'string' || typeof other == 'string') {
  6548. value = baseToString(value);
  6549. other = baseToString(other);
  6550. } else {
  6551. value = baseToNumber(value);
  6552. other = baseToNumber(other);
  6553. }
  6554. result = operator(value, other);
  6555. }
  6556. return result;
  6557. };
  6558. }
  6559. /**
  6560. * Creates a function like `_.over`.
  6561. *
  6562. * @private
  6563. * @param {Function} arrayFunc The function to iterate over iteratees.
  6564. * @returns {Function} Returns the new over function.
  6565. */
  6566. function createOver(arrayFunc) {
  6567. return flatRest(function(iteratees) {
  6568. iteratees = arrayMap(iteratees, baseUnary(getIteratee()));
  6569. return baseRest(function(args) {
  6570. var thisArg = this;
  6571. return arrayFunc(iteratees, function(iteratee) {
  6572. return apply(iteratee, thisArg, args);
  6573. });
  6574. });
  6575. });
  6576. }
  6577. /**
  6578. * Creates the padding for `string` based on `length`. The `chars` string
  6579. * is truncated if the number of characters exceeds `length`.
  6580. *
  6581. * @private
  6582. * @param {number} length The padding length.
  6583. * @param {string} [chars=' '] The string used as padding.
  6584. * @returns {string} Returns the padding for `string`.
  6585. */
  6586. function createPadding(length, chars) {
  6587. chars = chars === undefined ? ' ' : baseToString(chars);
  6588. var charsLength = chars.length;
  6589. if (charsLength < 2) {
  6590. return charsLength ? baseRepeat(chars, length) : chars;
  6591. }
  6592. var result = baseRepeat(chars, nativeCeil(length / stringSize(chars)));
  6593. return hasUnicode(chars)
  6594. ? castSlice(stringToArray(result), 0, length).join('')
  6595. : result.slice(0, length);
  6596. }
  6597. /**
  6598. * Creates a function that wraps `func` to invoke it with the `this` binding
  6599. * of `thisArg` and `partials` prepended to the arguments it receives.
  6600. *
  6601. * @private
  6602. * @param {Function} func The function to wrap.
  6603. * @param {number} bitmask The bitmask flags. See `createWrap` for more details.
  6604. * @param {*} thisArg The `this` binding of `func`.
  6605. * @param {Array} partials The arguments to prepend to those provided to
  6606. * the new function.
  6607. * @returns {Function} Returns the new wrapped function.
  6608. */
  6609. function createPartial(func, bitmask, thisArg, partials) {
  6610. var isBind = bitmask & WRAP_BIND_FLAG,
  6611. Ctor = createCtor(func);
  6612. function wrapper() {
  6613. var argsIndex = -1,
  6614. argsLength = arguments.length,
  6615. leftIndex = -1,
  6616. leftLength = partials.length,
  6617. args = Array(leftLength + argsLength),
  6618. fn = (this && this !== root && this instanceof wrapper) ? Ctor : func;
  6619. while (++leftIndex < leftLength) {
  6620. args[leftIndex] = partials[leftIndex];
  6621. }
  6622. while (argsLength--) {
  6623. args[leftIndex++] = arguments[++argsIndex];
  6624. }
  6625. return apply(fn, isBind ? thisArg : this, args);
  6626. }
  6627. return wrapper;
  6628. }
  6629. /**
  6630. * Creates a `_.range` or `_.rangeRight` function.
  6631. *
  6632. * @private
  6633. * @param {boolean} [fromRight] Specify iterating from right to left.
  6634. * @returns {Function} Returns the new range function.
  6635. */
  6636. function createRange(fromRight) {
  6637. return function(start, end, step) {
  6638. if (step && typeof step != 'number' && isIterateeCall(start, end, step)) {
  6639. end = step = undefined;
  6640. }
  6641. // Ensure the sign of `-0` is preserved.
  6642. start = toFinite(start);
  6643. if (end === undefined) {
  6644. end = start;
  6645. start = 0;
  6646. } else {
  6647. end = toFinite(end);
  6648. }
  6649. step = step === undefined ? (start < end ? 1 : -1) : toFinite(step);
  6650. return baseRange(start, end, step, fromRight);
  6651. };
  6652. }
  6653. /**
  6654. * Creates a function that performs a relational operation on two values.
  6655. *
  6656. * @private
  6657. * @param {Function} operator The function to perform the operation.
  6658. * @returns {Function} Returns the new relational operation function.
  6659. */
  6660. function createRelationalOperation(operator) {
  6661. return function(value, other) {
  6662. if (!(typeof value == 'string' && typeof other == 'string')) {
  6663. value = toNumber(value);
  6664. other = toNumber(other);
  6665. }
  6666. return operator(value, other);
  6667. };
  6668. }
  6669. /**
  6670. * Creates a function that wraps `func` to continue currying.
  6671. *
  6672. * @private
  6673. * @param {Function} func The function to wrap.
  6674. * @param {number} bitmask The bitmask flags. See `createWrap` for more details.
  6675. * @param {Function} wrapFunc The function to create the `func` wrapper.
  6676. * @param {*} placeholder The placeholder value.
  6677. * @param {*} [thisArg] The `this` binding of `func`.
  6678. * @param {Array} [partials] The arguments to prepend to those provided to
  6679. * the new function.
  6680. * @param {Array} [holders] The `partials` placeholder indexes.
  6681. * @param {Array} [argPos] The argument positions of the new function.
  6682. * @param {number} [ary] The arity cap of `func`.
  6683. * @param {number} [arity] The arity of `func`.
  6684. * @returns {Function} Returns the new wrapped function.
  6685. */
  6686. function createRecurry(func, bitmask, wrapFunc, placeholder, thisArg, partials, holders, argPos, ary, arity) {
  6687. var isCurry = bitmask & WRAP_CURRY_FLAG,
  6688. newHolders = isCurry ? holders : undefined,
  6689. newHoldersRight = isCurry ? undefined : holders,
  6690. newPartials = isCurry ? partials : undefined,
  6691. newPartialsRight = isCurry ? undefined : partials;
  6692. bitmask |= (isCurry ? WRAP_PARTIAL_FLAG : WRAP_PARTIAL_RIGHT_FLAG);
  6693. bitmask &= ~(isCurry ? WRAP_PARTIAL_RIGHT_FLAG : WRAP_PARTIAL_FLAG);
  6694. if (!(bitmask & WRAP_CURRY_BOUND_FLAG)) {
  6695. bitmask &= ~(WRAP_BIND_FLAG | WRAP_BIND_KEY_FLAG);
  6696. }
  6697. var newData = [
  6698. func, bitmask, thisArg, newPartials, newHolders, newPartialsRight,
  6699. newHoldersRight, argPos, ary, arity
  6700. ];
  6701. var result = wrapFunc.apply(undefined, newData);
  6702. if (isLaziable(func)) {
  6703. setData(result, newData);
  6704. }
  6705. result.placeholder = placeholder;
  6706. return setWrapToString(result, func, bitmask);
  6707. }
  6708. /**
  6709. * Creates a function like `_.round`.
  6710. *
  6711. * @private
  6712. * @param {string} methodName The name of the `Math` method to use when rounding.
  6713. * @returns {Function} Returns the new round function.
  6714. */
  6715. function createRound(methodName) {
  6716. var func = Math[methodName];
  6717. return function(number, precision) {
  6718. number = toNumber(number);
  6719. precision = precision == null ? 0 : nativeMin(toInteger(precision), 292);
  6720. if (precision && nativeIsFinite(number)) {
  6721. // Shift with exponential notation to avoid floating-point issues.
  6722. // See [MDN](https://mdn.io/round#Examples) for more details.
  6723. var pair = (toString(number) + 'e').split('e'),
  6724. value = func(pair[0] + 'e' + (+pair[1] + precision));
  6725. pair = (toString(value) + 'e').split('e');
  6726. return +(pair[0] + 'e' + (+pair[1] - precision));
  6727. }
  6728. return func(number);
  6729. };
  6730. }
  6731. /**
  6732. * Creates a set object of `values`.
  6733. *
  6734. * @private
  6735. * @param {Array} values The values to add to the set.
  6736. * @returns {Object} Returns the new set.
  6737. */
  6738. var createSet = !(Set && (1 / setToArray(new Set([,-0]))[1]) == INFINITY) ? noop : function(values) {
  6739. return new Set(values);
  6740. };
  6741. /**
  6742. * Creates a `_.toPairs` or `_.toPairsIn` function.
  6743. *
  6744. * @private
  6745. * @param {Function} keysFunc The function to get the keys of a given object.
  6746. * @returns {Function} Returns the new pairs function.
  6747. */
  6748. function createToPairs(keysFunc) {
  6749. return function(object) {
  6750. var tag = getTag(object);
  6751. if (tag == mapTag) {
  6752. return mapToArray(object);
  6753. }
  6754. if (tag == setTag) {
  6755. return setToPairs(object);
  6756. }
  6757. return baseToPairs(object, keysFunc(object));
  6758. };
  6759. }
  6760. /**
  6761. * Creates a function that either curries or invokes `func` with optional
  6762. * `this` binding and partially applied arguments.
  6763. *
  6764. * @private
  6765. * @param {Function|string} func The function or method name to wrap.
  6766. * @param {number} bitmask The bitmask flags.
  6767. * 1 - `_.bind`
  6768. * 2 - `_.bindKey`
  6769. * 4 - `_.curry` or `_.curryRight` of a bound function
  6770. * 8 - `_.curry`
  6771. * 16 - `_.curryRight`
  6772. * 32 - `_.partial`
  6773. * 64 - `_.partialRight`
  6774. * 128 - `_.rearg`
  6775. * 256 - `_.ary`
  6776. * 512 - `_.flip`
  6777. * @param {*} [thisArg] The `this` binding of `func`.
  6778. * @param {Array} [partials] The arguments to be partially applied.
  6779. * @param {Array} [holders] The `partials` placeholder indexes.
  6780. * @param {Array} [argPos] The argument positions of the new function.
  6781. * @param {number} [ary] The arity cap of `func`.
  6782. * @param {number} [arity] The arity of `func`.
  6783. * @returns {Function} Returns the new wrapped function.
  6784. */
  6785. function createWrap(func, bitmask, thisArg, partials, holders, argPos, ary, arity) {
  6786. var isBindKey = bitmask & WRAP_BIND_KEY_FLAG;
  6787. if (!isBindKey && typeof func != 'function') {
  6788. throw new TypeError(FUNC_ERROR_TEXT);
  6789. }
  6790. var length = partials ? partials.length : 0;
  6791. if (!length) {
  6792. bitmask &= ~(WRAP_PARTIAL_FLAG | WRAP_PARTIAL_RIGHT_FLAG);
  6793. partials = holders = undefined;
  6794. }
  6795. ary = ary === undefined ? ary : nativeMax(toInteger(ary), 0);
  6796. arity = arity === undefined ? arity : toInteger(arity);
  6797. length -= holders ? holders.length : 0;
  6798. if (bitmask & WRAP_PARTIAL_RIGHT_FLAG) {
  6799. var partialsRight = partials,
  6800. holdersRight = holders;
  6801. partials = holders = undefined;
  6802. }
  6803. var data = isBindKey ? undefined : getData(func);
  6804. var newData = [
  6805. func, bitmask, thisArg, partials, holders, partialsRight, holdersRight,
  6806. argPos, ary, arity
  6807. ];
  6808. if (data) {
  6809. mergeData(newData, data);
  6810. }
  6811. func = newData[0];
  6812. bitmask = newData[1];
  6813. thisArg = newData[2];
  6814. partials = newData[3];
  6815. holders = newData[4];
  6816. arity = newData[9] = newData[9] === undefined
  6817. ? (isBindKey ? 0 : func.length)
  6818. : nativeMax(newData[9] - length, 0);
  6819. if (!arity && bitmask & (WRAP_CURRY_FLAG | WRAP_CURRY_RIGHT_FLAG)) {
  6820. bitmask &= ~(WRAP_CURRY_FLAG | WRAP_CURRY_RIGHT_FLAG);
  6821. }
  6822. if (!bitmask || bitmask == WRAP_BIND_FLAG) {
  6823. var result = createBind(func, bitmask, thisArg);
  6824. } else if (bitmask == WRAP_CURRY_FLAG || bitmask == WRAP_CURRY_RIGHT_FLAG) {
  6825. result = createCurry(func, bitmask, arity);
  6826. } else if ((bitmask == WRAP_PARTIAL_FLAG || bitmask == (WRAP_BIND_FLAG | WRAP_PARTIAL_FLAG)) && !holders.length) {
  6827. result = createPartial(func, bitmask, thisArg, partials);
  6828. } else {
  6829. result = createHybrid.apply(undefined, newData);
  6830. }
  6831. var setter = data ? baseSetData : setData;
  6832. return setWrapToString(setter(result, newData), func, bitmask);
  6833. }
  6834. /**
  6835. * Used by `_.defaults` to customize its `_.assignIn` use to assign properties
  6836. * of source objects to the destination object for all destination properties
  6837. * that resolve to `undefined`.
  6838. *
  6839. * @private
  6840. * @param {*} objValue The destination value.
  6841. * @param {*} srcValue The source value.
  6842. * @param {string} key The key of the property to assign.
  6843. * @param {Object} object The parent object of `objValue`.
  6844. * @returns {*} Returns the value to assign.
  6845. */
  6846. function customDefaultsAssignIn(objValue, srcValue, key, object) {
  6847. if (objValue === undefined ||
  6848. (eq(objValue, objectProto[key]) && !hasOwnProperty.call(object, key))) {
  6849. return srcValue;
  6850. }
  6851. return objValue;
  6852. }
  6853. /**
  6854. * Used by `_.defaultsDeep` to customize its `_.merge` use to merge source
  6855. * objects into destination objects that are passed thru.
  6856. *
  6857. * @private
  6858. * @param {*} objValue The destination value.
  6859. * @param {*} srcValue The source value.
  6860. * @param {string} key The key of the property to merge.
  6861. * @param {Object} object The parent object of `objValue`.
  6862. * @param {Object} source The parent object of `srcValue`.
  6863. * @param {Object} [stack] Tracks traversed source values and their merged
  6864. * counterparts.
  6865. * @returns {*} Returns the value to assign.
  6866. */
  6867. function customDefaultsMerge(objValue, srcValue, key, object, source, stack) {
  6868. if (isObject(objValue) && isObject(srcValue)) {
  6869. // Recursively merge objects and arrays (susceptible to call stack limits).
  6870. stack.set(srcValue, objValue);
  6871. baseMerge(objValue, srcValue, undefined, customDefaultsMerge, stack);
  6872. stack['delete'](srcValue);
  6873. }
  6874. return objValue;
  6875. }
  6876. /**
  6877. * Used by `_.omit` to customize its `_.cloneDeep` use to only clone plain
  6878. * objects.
  6879. *
  6880. * @private
  6881. * @param {*} value The value to inspect.
  6882. * @param {string} key The key of the property to inspect.
  6883. * @returns {*} Returns the uncloned value or `undefined` to defer cloning to `_.cloneDeep`.
  6884. */
  6885. function customOmitClone(value) {
  6886. return isPlainObject(value) ? undefined : value;
  6887. }
  6888. /**
  6889. * A specialized version of `baseIsEqualDeep` for arrays with support for
  6890. * partial deep comparisons.
  6891. *
  6892. * @private
  6893. * @param {Array} array The array to compare.
  6894. * @param {Array} other The other array to compare.
  6895. * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.
  6896. * @param {Function} customizer The function to customize comparisons.
  6897. * @param {Function} equalFunc The function to determine equivalents of values.
  6898. * @param {Object} stack Tracks traversed `array` and `other` objects.
  6899. * @returns {boolean} Returns `true` if the arrays are equivalent, else `false`.
  6900. */
  6901. function equalArrays(array, other, bitmask, customizer, equalFunc, stack) {
  6902. var isPartial = bitmask & COMPARE_PARTIAL_FLAG,
  6903. arrLength = array.length,
  6904. othLength = other.length;
  6905. if (arrLength != othLength && !(isPartial && othLength > arrLength)) {
  6906. return false;
  6907. }
  6908. // Check that cyclic values are equal.
  6909. var arrStacked = stack.get(array);
  6910. var othStacked = stack.get(other);
  6911. if (arrStacked && othStacked) {
  6912. return arrStacked == other && othStacked == array;
  6913. }
  6914. var index = -1,
  6915. result = true,
  6916. seen = (bitmask & COMPARE_UNORDERED_FLAG) ? new SetCache : undefined;
  6917. stack.set(array, other);
  6918. stack.set(other, array);
  6919. // Ignore non-index properties.
  6920. while (++index < arrLength) {
  6921. var arrValue = array[index],
  6922. othValue = other[index];
  6923. if (customizer) {
  6924. var compared = isPartial
  6925. ? customizer(othValue, arrValue, index, other, array, stack)
  6926. : customizer(arrValue, othValue, index, array, other, stack);
  6927. }
  6928. if (compared !== undefined) {
  6929. if (compared) {
  6930. continue;
  6931. }
  6932. result = false;
  6933. break;
  6934. }
  6935. // Recursively compare arrays (susceptible to call stack limits).
  6936. if (seen) {
  6937. if (!arraySome(other, function(othValue, othIndex) {
  6938. if (!cacheHas(seen, othIndex) &&
  6939. (arrValue === othValue || equalFunc(arrValue, othValue, bitmask, customizer, stack))) {
  6940. return seen.push(othIndex);
  6941. }
  6942. })) {
  6943. result = false;
  6944. break;
  6945. }
  6946. } else if (!(
  6947. arrValue === othValue ||
  6948. equalFunc(arrValue, othValue, bitmask, customizer, stack)
  6949. )) {
  6950. result = false;
  6951. break;
  6952. }
  6953. }
  6954. stack['delete'](array);
  6955. stack['delete'](other);
  6956. return result;
  6957. }
  6958. /**
  6959. * A specialized version of `baseIsEqualDeep` for comparing objects of
  6960. * the same `toStringTag`.
  6961. *
  6962. * **Note:** This function only supports comparing values with tags of
  6963. * `Boolean`, `Date`, `Error`, `Number`, `RegExp`, or `String`.
  6964. *
  6965. * @private
  6966. * @param {Object} object The object to compare.
  6967. * @param {Object} other The other object to compare.
  6968. * @param {string} tag The `toStringTag` of the objects to compare.
  6969. * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.
  6970. * @param {Function} customizer The function to customize comparisons.
  6971. * @param {Function} equalFunc The function to determine equivalents of values.
  6972. * @param {Object} stack Tracks traversed `object` and `other` objects.
  6973. * @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
  6974. */
  6975. function equalByTag(object, other, tag, bitmask, customizer, equalFunc, stack) {
  6976. switch (tag) {
  6977. case dataViewTag:
  6978. if ((object.byteLength != other.byteLength) ||
  6979. (object.byteOffset != other.byteOffset)) {
  6980. return false;
  6981. }
  6982. object = object.buffer;
  6983. other = other.buffer;
  6984. case arrayBufferTag:
  6985. if ((object.byteLength != other.byteLength) ||
  6986. !equalFunc(new Uint8Array(object), new Uint8Array(other))) {
  6987. return false;
  6988. }
  6989. return true;
  6990. case boolTag:
  6991. case dateTag:
  6992. case numberTag:
  6993. // Coerce booleans to `1` or `0` and dates to milliseconds.
  6994. // Invalid dates are coerced to `NaN`.
  6995. return eq(+object, +other);
  6996. case errorTag:
  6997. return object.name == other.name && object.message == other.message;
  6998. case regexpTag:
  6999. case stringTag:
  7000. // Coerce regexes to strings and treat strings, primitives and objects,
  7001. // as equal. See http://www.ecma-international.org/ecma-262/7.0/#sec-regexp.prototype.tostring
  7002. // for more details.
  7003. return object == (other + '');
  7004. case mapTag:
  7005. var convert = mapToArray;
  7006. case setTag:
  7007. var isPartial = bitmask & COMPARE_PARTIAL_FLAG;
  7008. convert || (convert = setToArray);
  7009. if (object.size != other.size && !isPartial) {
  7010. return false;
  7011. }
  7012. // Assume cyclic values are equal.
  7013. var stacked = stack.get(object);
  7014. if (stacked) {
  7015. return stacked == other;
  7016. }
  7017. bitmask |= COMPARE_UNORDERED_FLAG;
  7018. // Recursively compare objects (susceptible to call stack limits).
  7019. stack.set(object, other);
  7020. var result = equalArrays(convert(object), convert(other), bitmask, customizer, equalFunc, stack);
  7021. stack['delete'](object);
  7022. return result;
  7023. case symbolTag:
  7024. if (symbolValueOf) {
  7025. return symbolValueOf.call(object) == symbolValueOf.call(other);
  7026. }
  7027. }
  7028. return false;
  7029. }
  7030. /**
  7031. * A specialized version of `baseIsEqualDeep` for objects with support for
  7032. * partial deep comparisons.
  7033. *
  7034. * @private
  7035. * @param {Object} object The object to compare.
  7036. * @param {Object} other The other object to compare.
  7037. * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.
  7038. * @param {Function} customizer The function to customize comparisons.
  7039. * @param {Function} equalFunc The function to determine equivalents of values.
  7040. * @param {Object} stack Tracks traversed `object` and `other` objects.
  7041. * @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
  7042. */
  7043. function equalObjects(object, other, bitmask, customizer, equalFunc, stack) {
  7044. var isPartial = bitmask & COMPARE_PARTIAL_FLAG,
  7045. objProps = getAllKeys(object),
  7046. objLength = objProps.length,
  7047. othProps = getAllKeys(other),
  7048. othLength = othProps.length;
  7049. if (objLength != othLength && !isPartial) {
  7050. return false;
  7051. }
  7052. var index = objLength;
  7053. while (index--) {
  7054. var key = objProps[index];
  7055. if (!(isPartial ? key in other : hasOwnProperty.call(other, key))) {
  7056. return false;
  7057. }
  7058. }
  7059. // Check that cyclic values are equal.
  7060. var objStacked = stack.get(object);
  7061. var othStacked = stack.get(other);
  7062. if (objStacked && othStacked) {
  7063. return objStacked == other && othStacked == object;
  7064. }
  7065. var result = true;
  7066. stack.set(object, other);
  7067. stack.set(other, object);
  7068. var skipCtor = isPartial;
  7069. while (++index < objLength) {
  7070. key = objProps[index];
  7071. var objValue = object[key],
  7072. othValue = other[key];
  7073. if (customizer) {
  7074. var compared = isPartial
  7075. ? customizer(othValue, objValue, key, other, object, stack)
  7076. : customizer(objValue, othValue, key, object, other, stack);
  7077. }
  7078. // Recursively compare objects (susceptible to call stack limits).
  7079. if (!(compared === undefined
  7080. ? (objValue === othValue || equalFunc(objValue, othValue, bitmask, customizer, stack))
  7081. : compared
  7082. )) {
  7083. result = false;
  7084. break;
  7085. }
  7086. skipCtor || (skipCtor = key == 'constructor');
  7087. }
  7088. if (result && !skipCtor) {
  7089. var objCtor = object.constructor,
  7090. othCtor = other.constructor;
  7091. // Non `Object` object instances with different constructors are not equal.
  7092. if (objCtor != othCtor &&
  7093. ('constructor' in object && 'constructor' in other) &&
  7094. !(typeof objCtor == 'function' && objCtor instanceof objCtor &&
  7095. typeof othCtor == 'function' && othCtor instanceof othCtor)) {
  7096. result = false;
  7097. }
  7098. }
  7099. stack['delete'](object);
  7100. stack['delete'](other);
  7101. return result;
  7102. }
  7103. /**
  7104. * A specialized version of `baseRest` which flattens the rest array.
  7105. *
  7106. * @private
  7107. * @param {Function} func The function to apply a rest parameter to.
  7108. * @returns {Function} Returns the new function.
  7109. */
  7110. function flatRest(func) {
  7111. return setToString(overRest(func, undefined, flatten), func + '');
  7112. }
  7113. /**
  7114. * Creates an array of own enumerable property names and symbols of `object`.
  7115. *
  7116. * @private
  7117. * @param {Object} object The object to query.
  7118. * @returns {Array} Returns the array of property names and symbols.
  7119. */
  7120. function getAllKeys(object) {
  7121. return baseGetAllKeys(object, keys, getSymbols);
  7122. }
  7123. /**
  7124. * Creates an array of own and inherited enumerable property names and
  7125. * symbols of `object`.
  7126. *
  7127. * @private
  7128. * @param {Object} object The object to query.
  7129. * @returns {Array} Returns the array of property names and symbols.
  7130. */
  7131. function getAllKeysIn(object) {
  7132. return baseGetAllKeys(object, keysIn, getSymbolsIn);
  7133. }
  7134. /**
  7135. * Gets metadata for `func`.
  7136. *
  7137. * @private
  7138. * @param {Function} func The function to query.
  7139. * @returns {*} Returns the metadata for `func`.
  7140. */
  7141. var getData = !metaMap ? noop : function(func) {
  7142. return metaMap.get(func);
  7143. };
  7144. /**
  7145. * Gets the name of `func`.
  7146. *
  7147. * @private
  7148. * @param {Function} func The function to query.
  7149. * @returns {string} Returns the function name.
  7150. */
  7151. function getFuncName(func) {
  7152. var result = (func.name + ''),
  7153. array = realNames[result],
  7154. length = hasOwnProperty.call(realNames, result) ? array.length : 0;
  7155. while (length--) {
  7156. var data = array[length],
  7157. otherFunc = data.func;
  7158. if (otherFunc == null || otherFunc == func) {
  7159. return data.name;
  7160. }
  7161. }
  7162. return result;
  7163. }
  7164. /**
  7165. * Gets the argument placeholder value for `func`.
  7166. *
  7167. * @private
  7168. * @param {Function} func The function to inspect.
  7169. * @returns {*} Returns the placeholder value.
  7170. */
  7171. function getHolder(func) {
  7172. var object = hasOwnProperty.call(lodash, 'placeholder') ? lodash : func;
  7173. return object.placeholder;
  7174. }
  7175. /**
  7176. * Gets the appropriate "iteratee" function. If `_.iteratee` is customized,
  7177. * this function returns the custom method, otherwise it returns `baseIteratee`.
  7178. * If arguments are provided, the chosen function is invoked with them and
  7179. * its result is returned.
  7180. *
  7181. * @private
  7182. * @param {*} [value] The value to convert to an iteratee.
  7183. * @param {number} [arity] The arity of the created iteratee.
  7184. * @returns {Function} Returns the chosen function or its result.
  7185. */
  7186. function getIteratee() {
  7187. var result = lodash.iteratee || iteratee;
  7188. result = result === iteratee ? baseIteratee : result;
  7189. return arguments.length ? result(arguments[0], arguments[1]) : result;
  7190. }
  7191. /**
  7192. * Gets the data for `map`.
  7193. *
  7194. * @private
  7195. * @param {Object} map The map to query.
  7196. * @param {string} key The reference key.
  7197. * @returns {*} Returns the map data.
  7198. */
  7199. function getMapData(map, key) {
  7200. var data = map.__data__;
  7201. return isKeyable(key)
  7202. ? data[typeof key == 'string' ? 'string' : 'hash']
  7203. : data.map;
  7204. }
  7205. /**
  7206. * Gets the property names, values, and compare flags of `object`.
  7207. *
  7208. * @private
  7209. * @param {Object} object The object to query.
  7210. * @returns {Array} Returns the match data of `object`.
  7211. */
  7212. function getMatchData(object) {
  7213. var result = keys(object),
  7214. length = result.length;
  7215. while (length--) {
  7216. var key = result[length],
  7217. value = object[key];
  7218. result[length] = [key, value, isStrictComparable(value)];
  7219. }
  7220. return result;
  7221. }
  7222. /**
  7223. * Gets the native function at `key` of `object`.
  7224. *
  7225. * @private
  7226. * @param {Object} object The object to query.
  7227. * @param {string} key The key of the method to get.
  7228. * @returns {*} Returns the function if it's native, else `undefined`.
  7229. */
  7230. function getNative(object, key) {
  7231. var value = getValue(object, key);
  7232. return baseIsNative(value) ? value : undefined;
  7233. }
  7234. /**
  7235. * A specialized version of `baseGetTag` which ignores `Symbol.toStringTag` values.
  7236. *
  7237. * @private
  7238. * @param {*} value The value to query.
  7239. * @returns {string} Returns the raw `toStringTag`.
  7240. */
  7241. function getRawTag(value) {
  7242. var isOwn = hasOwnProperty.call(value, symToStringTag),
  7243. tag = value[symToStringTag];
  7244. try {
  7245. value[symToStringTag] = undefined;
  7246. var unmasked = true;
  7247. } catch (e) {}
  7248. var result = nativeObjectToString.call(value);
  7249. if (unmasked) {
  7250. if (isOwn) {
  7251. value[symToStringTag] = tag;
  7252. } else {
  7253. delete value[symToStringTag];
  7254. }
  7255. }
  7256. return result;
  7257. }
  7258. /**
  7259. * Creates an array of the own enumerable symbols of `object`.
  7260. *
  7261. * @private
  7262. * @param {Object} object The object to query.
  7263. * @returns {Array} Returns the array of symbols.
  7264. */
  7265. var getSymbols = !nativeGetSymbols ? stubArray : function(object) {
  7266. if (object == null) {
  7267. return [];
  7268. }
  7269. object = Object(object);
  7270. return arrayFilter(nativeGetSymbols(object), function(symbol) {
  7271. return propertyIsEnumerable.call(object, symbol);
  7272. });
  7273. };
  7274. /**
  7275. * Creates an array of the own and inherited enumerable symbols of `object`.
  7276. *
  7277. * @private
  7278. * @param {Object} object The object to query.
  7279. * @returns {Array} Returns the array of symbols.
  7280. */
  7281. var getSymbolsIn = !nativeGetSymbols ? stubArray : function(object) {
  7282. var result = [];
  7283. while (object) {
  7284. arrayPush(result, getSymbols(object));
  7285. object = getPrototype(object);
  7286. }
  7287. return result;
  7288. };
  7289. /**
  7290. * Gets the `toStringTag` of `value`.
  7291. *
  7292. * @private
  7293. * @param {*} value The value to query.
  7294. * @returns {string} Returns the `toStringTag`.
  7295. */
  7296. var getTag = baseGetTag;
  7297. // Fallback for data views, maps, sets, and weak maps in IE 11 and promises in Node.js < 6.
  7298. if ((DataView && getTag(new DataView(new ArrayBuffer(1))) != dataViewTag) ||
  7299. (Map && getTag(new Map) != mapTag) ||
  7300. (Promise && getTag(Promise.resolve()) != promiseTag) ||
  7301. (Set && getTag(new Set) != setTag) ||
  7302. (WeakMap && getTag(new WeakMap) != weakMapTag)) {
  7303. getTag = function(value) {
  7304. var result = baseGetTag(value),
  7305. Ctor = result == objectTag ? value.constructor : undefined,
  7306. ctorString = Ctor ? toSource(Ctor) : '';
  7307. if (ctorString) {
  7308. switch (ctorString) {
  7309. case dataViewCtorString: return dataViewTag;
  7310. case mapCtorString: return mapTag;
  7311. case promiseCtorString: return promiseTag;
  7312. case setCtorString: return setTag;
  7313. case weakMapCtorString: return weakMapTag;
  7314. }
  7315. }
  7316. return result;
  7317. };
  7318. }
  7319. /**
  7320. * Gets the view, applying any `transforms` to the `start` and `end` positions.
  7321. *
  7322. * @private
  7323. * @param {number} start The start of the view.
  7324. * @param {number} end The end of the view.
  7325. * @param {Array} transforms The transformations to apply to the view.
  7326. * @returns {Object} Returns an object containing the `start` and `end`
  7327. * positions of the view.
  7328. */
  7329. function getView(start, end, transforms) {
  7330. var index = -1,
  7331. length = transforms.length;
  7332. while (++index < length) {
  7333. var data = transforms[index],
  7334. size = data.size;
  7335. switch (data.type) {
  7336. case 'drop': start += size; break;
  7337. case 'dropRight': end -= size; break;
  7338. case 'take': end = nativeMin(end, start + size); break;
  7339. case 'takeRight': start = nativeMax(start, end - size); break;
  7340. }
  7341. }
  7342. return { 'start': start, 'end': end };
  7343. }
  7344. /**
  7345. * Extracts wrapper details from the `source` body comment.
  7346. *
  7347. * @private
  7348. * @param {string} source The source to inspect.
  7349. * @returns {Array} Returns the wrapper details.
  7350. */
  7351. function getWrapDetails(source) {
  7352. var match = source.match(reWrapDetails);
  7353. return match ? match[1].split(reSplitDetails) : [];
  7354. }
  7355. /**
  7356. * Checks if `path` exists on `object`.
  7357. *
  7358. * @private
  7359. * @param {Object} object The object to query.
  7360. * @param {Array|string} path The path to check.
  7361. * @param {Function} hasFunc The function to check properties.
  7362. * @returns {boolean} Returns `true` if `path` exists, else `false`.
  7363. */
  7364. function hasPath(object, path, hasFunc) {
  7365. path = castPath(path, object);
  7366. var index = -1,
  7367. length = path.length,
  7368. result = false;
  7369. while (++index < length) {
  7370. var key = toKey(path[index]);
  7371. if (!(result = object != null && hasFunc(object, key))) {
  7372. break;
  7373. }
  7374. object = object[key];
  7375. }
  7376. if (result || ++index != length) {
  7377. return result;
  7378. }
  7379. length = object == null ? 0 : object.length;
  7380. return !!length && isLength(length) && isIndex(key, length) &&
  7381. (isArray(object) || isArguments(object));
  7382. }
  7383. /**
  7384. * Initializes an array clone.
  7385. *
  7386. * @private
  7387. * @param {Array} array The array to clone.
  7388. * @returns {Array} Returns the initialized clone.
  7389. */
  7390. function initCloneArray(array) {
  7391. var length = array.length,
  7392. result = new array.constructor(length);
  7393. // Add properties assigned by `RegExp#exec`.
  7394. if (length && typeof array[0] == 'string' && hasOwnProperty.call(array, 'index')) {
  7395. result.index = array.index;
  7396. result.input = array.input;
  7397. }
  7398. return result;
  7399. }
  7400. /**
  7401. * Initializes an object clone.
  7402. *
  7403. * @private
  7404. * @param {Object} object The object to clone.
  7405. * @returns {Object} Returns the initialized clone.
  7406. */
  7407. function initCloneObject(object) {
  7408. return (typeof object.constructor == 'function' && !isPrototype(object))
  7409. ? baseCreate(getPrototype(object))
  7410. : {};
  7411. }
  7412. /**
  7413. * Initializes an object clone based on its `toStringTag`.
  7414. *
  7415. * **Note:** This function only supports cloning values with tags of
  7416. * `Boolean`, `Date`, `Error`, `Map`, `Number`, `RegExp`, `Set`, or `String`.
  7417. *
  7418. * @private
  7419. * @param {Object} object The object to clone.
  7420. * @param {string} tag The `toStringTag` of the object to clone.
  7421. * @param {boolean} [isDeep] Specify a deep clone.
  7422. * @returns {Object} Returns the initialized clone.
  7423. */
  7424. function initCloneByTag(object, tag, isDeep) {
  7425. var Ctor = object.constructor;
  7426. switch (tag) {
  7427. case arrayBufferTag:
  7428. return cloneArrayBuffer(object);
  7429. case boolTag:
  7430. case dateTag:
  7431. return new Ctor(+object);
  7432. case dataViewTag:
  7433. return cloneDataView(object, isDeep);
  7434. case float32Tag: case float64Tag:
  7435. case int8Tag: case int16Tag: case int32Tag:
  7436. case uint8Tag: case uint8ClampedTag: case uint16Tag: case uint32Tag:
  7437. return cloneTypedArray(object, isDeep);
  7438. case mapTag:
  7439. return new Ctor;
  7440. case numberTag:
  7441. case stringTag:
  7442. return new Ctor(object);
  7443. case regexpTag:
  7444. return cloneRegExp(object);
  7445. case setTag:
  7446. return new Ctor;
  7447. case symbolTag:
  7448. return cloneSymbol(object);
  7449. }
  7450. }
  7451. /**
  7452. * Inserts wrapper `details` in a comment at the top of the `source` body.
  7453. *
  7454. * @private
  7455. * @param {string} source The source to modify.
  7456. * @returns {Array} details The details to insert.
  7457. * @returns {string} Returns the modified source.
  7458. */
  7459. function insertWrapDetails(source, details) {
  7460. var length = details.length;
  7461. if (!length) {
  7462. return source;
  7463. }
  7464. var lastIndex = length - 1;
  7465. details[lastIndex] = (length > 1 ? '& ' : '') + details[lastIndex];
  7466. details = details.join(length > 2 ? ', ' : ' ');
  7467. return source.replace(reWrapComment, '{\n/* [wrapped with ' + details + '] */\n');
  7468. }
  7469. /**
  7470. * Checks if `value` is a flattenable `arguments` object or array.
  7471. *
  7472. * @private
  7473. * @param {*} value The value to check.
  7474. * @returns {boolean} Returns `true` if `value` is flattenable, else `false`.
  7475. */
  7476. function isFlattenable(value) {
  7477. return isArray(value) || isArguments(value) ||
  7478. !!(spreadableSymbol && value && value[spreadableSymbol]);
  7479. }
  7480. /**
  7481. * Checks if `value` is a valid array-like index.
  7482. *
  7483. * @private
  7484. * @param {*} value The value to check.
  7485. * @param {number} [length=MAX_SAFE_INTEGER] The upper bounds of a valid index.
  7486. * @returns {boolean} Returns `true` if `value` is a valid index, else `false`.
  7487. */
  7488. function isIndex(value, length) {
  7489. var type = typeof value;
  7490. length = length == null ? MAX_SAFE_INTEGER : length;
  7491. return !!length &&
  7492. (type == 'number' ||
  7493. (type != 'symbol' && reIsUint.test(value))) &&
  7494. (value > -1 && value % 1 == 0 && value < length);
  7495. }
  7496. /**
  7497. * Checks if the given arguments are from an iteratee call.
  7498. *
  7499. * @private
  7500. * @param {*} value The potential iteratee value argument.
  7501. * @param {*} index The potential iteratee index or key argument.
  7502. * @param {*} object The potential iteratee object argument.
  7503. * @returns {boolean} Returns `true` if the arguments are from an iteratee call,
  7504. * else `false`.
  7505. */
  7506. function isIterateeCall(value, index, object) {
  7507. if (!isObject(object)) {
  7508. return false;
  7509. }
  7510. var type = typeof index;
  7511. if (type == 'number'
  7512. ? (isArrayLike(object) && isIndex(index, object.length))
  7513. : (type == 'string' && index in object)
  7514. ) {
  7515. return eq(object[index], value);
  7516. }
  7517. return false;
  7518. }
  7519. /**
  7520. * Checks if `value` is a property name and not a property path.
  7521. *
  7522. * @private
  7523. * @param {*} value The value to check.
  7524. * @param {Object} [object] The object to query keys on.
  7525. * @returns {boolean} Returns `true` if `value` is a property name, else `false`.
  7526. */
  7527. function isKey(value, object) {
  7528. if (isArray(value)) {
  7529. return false;
  7530. }
  7531. var type = typeof value;
  7532. if (type == 'number' || type == 'symbol' || type == 'boolean' ||
  7533. value == null || isSymbol(value)) {
  7534. return true;
  7535. }
  7536. return reIsPlainProp.test(value) || !reIsDeepProp.test(value) ||
  7537. (object != null && value in Object(object));
  7538. }
  7539. /**
  7540. * Checks if `value` is suitable for use as unique object key.
  7541. *
  7542. * @private
  7543. * @param {*} value The value to check.
  7544. * @returns {boolean} Returns `true` if `value` is suitable, else `false`.
  7545. */
  7546. function isKeyable(value) {
  7547. var type = typeof value;
  7548. return (type == 'string' || type == 'number' || type == 'symbol' || type == 'boolean')
  7549. ? (value !== '__proto__')
  7550. : (value === null);
  7551. }
  7552. /**
  7553. * Checks if `func` has a lazy counterpart.
  7554. *
  7555. * @private
  7556. * @param {Function} func The function to check.
  7557. * @returns {boolean} Returns `true` if `func` has a lazy counterpart,
  7558. * else `false`.
  7559. */
  7560. function isLaziable(func) {
  7561. var funcName = getFuncName(func),
  7562. other = lodash[funcName];
  7563. if (typeof other != 'function' || !(funcName in LazyWrapper.prototype)) {
  7564. return false;
  7565. }
  7566. if (func === other) {
  7567. return true;
  7568. }
  7569. var data = getData(other);
  7570. return !!data && func === data[0];
  7571. }
  7572. /**
  7573. * Checks if `func` has its source masked.
  7574. *
  7575. * @private
  7576. * @param {Function} func The function to check.
  7577. * @returns {boolean} Returns `true` if `func` is masked, else `false`.
  7578. */
  7579. function isMasked(func) {
  7580. return !!maskSrcKey && (maskSrcKey in func);
  7581. }
  7582. /**
  7583. * Checks if `func` is capable of being masked.
  7584. *
  7585. * @private
  7586. * @param {*} value The value to check.
  7587. * @returns {boolean} Returns `true` if `func` is maskable, else `false`.
  7588. */
  7589. var isMaskable = coreJsData ? isFunction : stubFalse;
  7590. /**
  7591. * Checks if `value` is likely a prototype object.
  7592. *
  7593. * @private
  7594. * @param {*} value The value to check.
  7595. * @returns {boolean} Returns `true` if `value` is a prototype, else `false`.
  7596. */
  7597. function isPrototype(value) {
  7598. var Ctor = value && value.constructor,
  7599. proto = (typeof Ctor == 'function' && Ctor.prototype) || objectProto;
  7600. return value === proto;
  7601. }
  7602. /**
  7603. * Checks if `value` is suitable for strict equality comparisons, i.e. `===`.
  7604. *
  7605. * @private
  7606. * @param {*} value The value to check.
  7607. * @returns {boolean} Returns `true` if `value` if suitable for strict
  7608. * equality comparisons, else `false`.
  7609. */
  7610. function isStrictComparable(value) {
  7611. return value === value && !isObject(value);
  7612. }
  7613. /**
  7614. * A specialized version of `matchesProperty` for source values suitable
  7615. * for strict equality comparisons, i.e. `===`.
  7616. *
  7617. * @private
  7618. * @param {string} key The key of the property to get.
  7619. * @param {*} srcValue The value to match.
  7620. * @returns {Function} Returns the new spec function.
  7621. */
  7622. function matchesStrictComparable(key, srcValue) {
  7623. return function(object) {
  7624. if (object == null) {
  7625. return false;
  7626. }
  7627. return object[key] === srcValue &&
  7628. (srcValue !== undefined || (key in Object(object)));
  7629. };
  7630. }
  7631. /**
  7632. * A specialized version of `_.memoize` which clears the memoized function's
  7633. * cache when it exceeds `MAX_MEMOIZE_SIZE`.
  7634. *
  7635. * @private
  7636. * @param {Function} func The function to have its output memoized.
  7637. * @returns {Function} Returns the new memoized function.
  7638. */
  7639. function memoizeCapped(func) {
  7640. var result = memoize(func, function(key) {
  7641. if (cache.size === MAX_MEMOIZE_SIZE) {
  7642. cache.clear();
  7643. }
  7644. return key;
  7645. });
  7646. var cache = result.cache;
  7647. return result;
  7648. }
  7649. /**
  7650. * Merges the function metadata of `source` into `data`.
  7651. *
  7652. * Merging metadata reduces the number of wrappers used to invoke a function.
  7653. * This is possible because methods like `_.bind`, `_.curry`, and `_.partial`
  7654. * may be applied regardless of execution order. Methods like `_.ary` and
  7655. * `_.rearg` modify function arguments, making the order in which they are
  7656. * executed important, preventing the merging of metadata. However, we make
  7657. * an exception for a safe combined case where curried functions have `_.ary`
  7658. * and or `_.rearg` applied.
  7659. *
  7660. * @private
  7661. * @param {Array} data The destination metadata.
  7662. * @param {Array} source The source metadata.
  7663. * @returns {Array} Returns `data`.
  7664. */
  7665. function mergeData(data, source) {
  7666. var bitmask = data[1],
  7667. srcBitmask = source[1],
  7668. newBitmask = bitmask | srcBitmask,
  7669. isCommon = newBitmask < (WRAP_BIND_FLAG | WRAP_BIND_KEY_FLAG | WRAP_ARY_FLAG);
  7670. var isCombo =
  7671. ((srcBitmask == WRAP_ARY_FLAG) && (bitmask == WRAP_CURRY_FLAG)) ||
  7672. ((srcBitmask == WRAP_ARY_FLAG) && (bitmask == WRAP_REARG_FLAG) && (data[7].length <= source[8])) ||
  7673. ((srcBitmask == (WRAP_ARY_FLAG | WRAP_REARG_FLAG)) && (source[7].length <= source[8]) && (bitmask == WRAP_CURRY_FLAG));
  7674. // Exit early if metadata can't be merged.
  7675. if (!(isCommon || isCombo)) {
  7676. return data;
  7677. }
  7678. // Use source `thisArg` if available.
  7679. if (srcBitmask & WRAP_BIND_FLAG) {
  7680. data[2] = source[2];
  7681. // Set when currying a bound function.
  7682. newBitmask |= bitmask & WRAP_BIND_FLAG ? 0 : WRAP_CURRY_BOUND_FLAG;
  7683. }
  7684. // Compose partial arguments.
  7685. var value = source[3];
  7686. if (value) {
  7687. var partials = data[3];
  7688. data[3] = partials ? composeArgs(partials, value, source[4]) : value;
  7689. data[4] = partials ? replaceHolders(data[3], PLACEHOLDER) : source[4];
  7690. }
  7691. // Compose partial right arguments.
  7692. value = source[5];
  7693. if (value) {
  7694. partials = data[5];
  7695. data[5] = partials ? composeArgsRight(partials, value, source[6]) : value;
  7696. data[6] = partials ? replaceHolders(data[5], PLACEHOLDER) : source[6];
  7697. }
  7698. // Use source `argPos` if available.
  7699. value = source[7];
  7700. if (value) {
  7701. data[7] = value;
  7702. }
  7703. // Use source `ary` if it's smaller.
  7704. if (srcBitmask & WRAP_ARY_FLAG) {
  7705. data[8] = data[8] == null ? source[8] : nativeMin(data[8], source[8]);
  7706. }
  7707. // Use source `arity` if one is not provided.
  7708. if (data[9] == null) {
  7709. data[9] = source[9];
  7710. }
  7711. // Use source `func` and merge bitmasks.
  7712. data[0] = source[0];
  7713. data[1] = newBitmask;
  7714. return data;
  7715. }
  7716. /**
  7717. * This function is like
  7718. * [`Object.keys`](http://ecma-international.org/ecma-262/7.0/#sec-object.keys)
  7719. * except that it includes inherited enumerable properties.
  7720. *
  7721. * @private
  7722. * @param {Object} object The object to query.
  7723. * @returns {Array} Returns the array of property names.
  7724. */
  7725. function nativeKeysIn(object) {
  7726. var result = [];
  7727. if (object != null) {
  7728. for (var key in Object(object)) {
  7729. result.push(key);
  7730. }
  7731. }
  7732. return result;
  7733. }
  7734. /**
  7735. * Converts `value` to a string using `Object.prototype.toString`.
  7736. *
  7737. * @private
  7738. * @param {*} value The value to convert.
  7739. * @returns {string} Returns the converted string.
  7740. */
  7741. function objectToString(value) {
  7742. return nativeObjectToString.call(value);
  7743. }
  7744. /**
  7745. * A specialized version of `baseRest` which transforms the rest array.
  7746. *
  7747. * @private
  7748. * @param {Function} func The function to apply a rest parameter to.
  7749. * @param {number} [start=func.length-1] The start position of the rest parameter.
  7750. * @param {Function} transform The rest array transform.
  7751. * @returns {Function} Returns the new function.
  7752. */
  7753. function overRest(func, start, transform) {
  7754. start = nativeMax(start === undefined ? (func.length - 1) : start, 0);
  7755. return function() {
  7756. var args = arguments,
  7757. index = -1,
  7758. length = nativeMax(args.length - start, 0),
  7759. array = Array(length);
  7760. while (++index < length) {
  7761. array[index] = args[start + index];
  7762. }
  7763. index = -1;
  7764. var otherArgs = Array(start + 1);
  7765. while (++index < start) {
  7766. otherArgs[index] = args[index];
  7767. }
  7768. otherArgs[start] = transform(array);
  7769. return apply(func, this, otherArgs);
  7770. };
  7771. }
  7772. /**
  7773. * Gets the parent value at `path` of `object`.
  7774. *
  7775. * @private
  7776. * @param {Object} object The object to query.
  7777. * @param {Array} path The path to get the parent value of.
  7778. * @returns {*} Returns the parent value.
  7779. */
  7780. function parent(object, path) {
  7781. return path.length < 2 ? object : baseGet(object, baseSlice(path, 0, -1));
  7782. }
  7783. /**
  7784. * Reorder `array` according to the specified indexes where the element at
  7785. * the first index is assigned as the first element, the element at
  7786. * the second index is assigned as the second element, and so on.
  7787. *
  7788. * @private
  7789. * @param {Array} array The array to reorder.
  7790. * @param {Array} indexes The arranged array indexes.
  7791. * @returns {Array} Returns `array`.
  7792. */
  7793. function reorder(array, indexes) {
  7794. var arrLength = array.length,
  7795. length = nativeMin(indexes.length, arrLength),
  7796. oldArray = copyArray(array);
  7797. while (length--) {
  7798. var index = indexes[length];
  7799. array[length] = isIndex(index, arrLength) ? oldArray[index] : undefined;
  7800. }
  7801. return array;
  7802. }
  7803. /**
  7804. * Gets the value at `key`, unless `key` is "__proto__" or "constructor".
  7805. *
  7806. * @private
  7807. * @param {Object} object The object to query.
  7808. * @param {string} key The key of the property to get.
  7809. * @returns {*} Returns the property value.
  7810. */
  7811. function safeGet(object, key) {
  7812. if (key === 'constructor' && typeof object[key] === 'function') {
  7813. return;
  7814. }
  7815. if (key == '__proto__') {
  7816. return;
  7817. }
  7818. return object[key];
  7819. }
  7820. /**
  7821. * Sets metadata for `func`.
  7822. *
  7823. * **Note:** If this function becomes hot, i.e. is invoked a lot in a short
  7824. * period of time, it will trip its breaker and transition to an identity
  7825. * function to avoid garbage collection pauses in V8. See
  7826. * [V8 issue 2070](https://bugs.chromium.org/p/v8/issues/detail?id=2070)
  7827. * for more details.
  7828. *
  7829. * @private
  7830. * @param {Function} func The function to associate metadata with.
  7831. * @param {*} data The metadata.
  7832. * @returns {Function} Returns `func`.
  7833. */
  7834. var setData = shortOut(baseSetData);
  7835. /**
  7836. * A simple wrapper around the global [`setTimeout`](https://mdn.io/setTimeout).
  7837. *
  7838. * @private
  7839. * @param {Function} func The function to delay.
  7840. * @param {number} wait The number of milliseconds to delay invocation.
  7841. * @returns {number|Object} Returns the timer id or timeout object.
  7842. */
  7843. var setTimeout = ctxSetTimeout || function(func, wait) {
  7844. return root.setTimeout(func, wait);
  7845. };
  7846. /**
  7847. * Sets the `toString` method of `func` to return `string`.
  7848. *
  7849. * @private
  7850. * @param {Function} func The function to modify.
  7851. * @param {Function} string The `toString` result.
  7852. * @returns {Function} Returns `func`.
  7853. */
  7854. var setToString = shortOut(baseSetToString);
  7855. /**
  7856. * Sets the `toString` method of `wrapper` to mimic the source of `reference`
  7857. * with wrapper details in a comment at the top of the source body.
  7858. *
  7859. * @private
  7860. * @param {Function} wrapper The function to modify.
  7861. * @param {Function} reference The reference function.
  7862. * @param {number} bitmask The bitmask flags. See `createWrap` for more details.
  7863. * @returns {Function} Returns `wrapper`.
  7864. */
  7865. function setWrapToString(wrapper, reference, bitmask) {
  7866. var source = (reference + '');
  7867. return setToString(wrapper, insertWrapDetails(source, updateWrapDetails(getWrapDetails(source), bitmask)));
  7868. }
  7869. /**
  7870. * Creates a function that'll short out and invoke `identity` instead
  7871. * of `func` when it's called `HOT_COUNT` or more times in `HOT_SPAN`
  7872. * milliseconds.
  7873. *
  7874. * @private
  7875. * @param {Function} func The function to restrict.
  7876. * @returns {Function} Returns the new shortable function.
  7877. */
  7878. function shortOut(func) {
  7879. var count = 0,
  7880. lastCalled = 0;
  7881. return function() {
  7882. var stamp = nativeNow(),
  7883. remaining = HOT_SPAN - (stamp - lastCalled);
  7884. lastCalled = stamp;
  7885. if (remaining > 0) {
  7886. if (++count >= HOT_COUNT) {
  7887. return arguments[0];
  7888. }
  7889. } else {
  7890. count = 0;
  7891. }
  7892. return func.apply(undefined, arguments);
  7893. };
  7894. }
  7895. /**
  7896. * A specialized version of `_.shuffle` which mutates and sets the size of `array`.
  7897. *
  7898. * @private
  7899. * @param {Array} array The array to shuffle.
  7900. * @param {number} [size=array.length] The size of `array`.
  7901. * @returns {Array} Returns `array`.
  7902. */
  7903. function shuffleSelf(array, size) {
  7904. var index = -1,
  7905. length = array.length,
  7906. lastIndex = length - 1;
  7907. size = size === undefined ? length : size;
  7908. while (++index < size) {
  7909. var rand = baseRandom(index, lastIndex),
  7910. value = array[rand];
  7911. array[rand] = array[index];
  7912. array[index] = value;
  7913. }
  7914. array.length = size;
  7915. return array;
  7916. }
  7917. /**
  7918. * Converts `string` to a property path array.
  7919. *
  7920. * @private
  7921. * @param {string} string The string to convert.
  7922. * @returns {Array} Returns the property path array.
  7923. */
  7924. var stringToPath = memoizeCapped(function(string) {
  7925. var result = [];
  7926. if (string.charCodeAt(0) === 46 /* . */) {
  7927. result.push('');
  7928. }
  7929. string.replace(rePropName, function(match, number, quote, subString) {
  7930. result.push(quote ? subString.replace(reEscapeChar, '$1') : (number || match));
  7931. });
  7932. return result;
  7933. });
  7934. /**
  7935. * Converts `value` to a string key if it's not a string or symbol.
  7936. *
  7937. * @private
  7938. * @param {*} value The value to inspect.
  7939. * @returns {string|symbol} Returns the key.
  7940. */
  7941. function toKey(value) {
  7942. if (typeof value == 'string' || isSymbol(value)) {
  7943. return value;
  7944. }
  7945. var result = (value + '');
  7946. return (result == '0' && (1 / value) == -INFINITY) ? '-0' : result;
  7947. }
  7948. /**
  7949. * Converts `func` to its source code.
  7950. *
  7951. * @private
  7952. * @param {Function} func The function to convert.
  7953. * @returns {string} Returns the source code.
  7954. */
  7955. function toSource(func) {
  7956. if (func != null) {
  7957. try {
  7958. return funcToString.call(func);
  7959. } catch (e) {}
  7960. try {
  7961. return (func + '');
  7962. } catch (e) {}
  7963. }
  7964. return '';
  7965. }
  7966. /**
  7967. * Updates wrapper `details` based on `bitmask` flags.
  7968. *
  7969. * @private
  7970. * @returns {Array} details The details to modify.
  7971. * @param {number} bitmask The bitmask flags. See `createWrap` for more details.
  7972. * @returns {Array} Returns `details`.
  7973. */
  7974. function updateWrapDetails(details, bitmask) {
  7975. arrayEach(wrapFlags, function(pair) {
  7976. var value = '_.' + pair[0];
  7977. if ((bitmask & pair[1]) && !arrayIncludes(details, value)) {
  7978. details.push(value);
  7979. }
  7980. });
  7981. return details.sort();
  7982. }
  7983. /**
  7984. * Creates a clone of `wrapper`.
  7985. *
  7986. * @private
  7987. * @param {Object} wrapper The wrapper to clone.
  7988. * @returns {Object} Returns the cloned wrapper.
  7989. */
  7990. function wrapperClone(wrapper) {
  7991. if (wrapper instanceof LazyWrapper) {
  7992. return wrapper.clone();
  7993. }
  7994. var result = new LodashWrapper(wrapper.__wrapped__, wrapper.__chain__);
  7995. result.__actions__ = copyArray(wrapper.__actions__);
  7996. result.__index__ = wrapper.__index__;
  7997. result.__values__ = wrapper.__values__;
  7998. return result;
  7999. }
  8000. /*------------------------------------------------------------------------*/
  8001. /**
  8002. * Creates an array of elements split into groups the length of `size`.
  8003. * If `array` can't be split evenly, the final chunk will be the remaining
  8004. * elements.
  8005. *
  8006. * @static
  8007. * @memberOf _
  8008. * @since 3.0.0
  8009. * @category Array
  8010. * @param {Array} array The array to process.
  8011. * @param {number} [size=1] The length of each chunk
  8012. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  8013. * @returns {Array} Returns the new array of chunks.
  8014. * @example
  8015. *
  8016. * _.chunk(['a', 'b', 'c', 'd'], 2);
  8017. * // => [['a', 'b'], ['c', 'd']]
  8018. *
  8019. * _.chunk(['a', 'b', 'c', 'd'], 3);
  8020. * // => [['a', 'b', 'c'], ['d']]
  8021. */
  8022. function chunk(array, size, guard) {
  8023. if ((guard ? isIterateeCall(array, size, guard) : size === undefined)) {
  8024. size = 1;
  8025. } else {
  8026. size = nativeMax(toInteger(size), 0);
  8027. }
  8028. var length = array == null ? 0 : array.length;
  8029. if (!length || size < 1) {
  8030. return [];
  8031. }
  8032. var index = 0,
  8033. resIndex = 0,
  8034. result = Array(nativeCeil(length / size));
  8035. while (index < length) {
  8036. result[resIndex++] = baseSlice(array, index, (index += size));
  8037. }
  8038. return result;
  8039. }
  8040. /**
  8041. * Creates an array with all falsey values removed. The values `false`, `null`,
  8042. * `0`, `""`, `undefined`, and `NaN` are falsey.
  8043. *
  8044. * @static
  8045. * @memberOf _
  8046. * @since 0.1.0
  8047. * @category Array
  8048. * @param {Array} array The array to compact.
  8049. * @returns {Array} Returns the new array of filtered values.
  8050. * @example
  8051. *
  8052. * _.compact([0, 1, false, 2, '', 3]);
  8053. * // => [1, 2, 3]
  8054. */
  8055. function compact(array) {
  8056. var index = -1,
  8057. length = array == null ? 0 : array.length,
  8058. resIndex = 0,
  8059. result = [];
  8060. while (++index < length) {
  8061. var value = array[index];
  8062. if (value) {
  8063. result[resIndex++] = value;
  8064. }
  8065. }
  8066. return result;
  8067. }
  8068. /**
  8069. * Creates a new array concatenating `array` with any additional arrays
  8070. * and/or values.
  8071. *
  8072. * @static
  8073. * @memberOf _
  8074. * @since 4.0.0
  8075. * @category Array
  8076. * @param {Array} array The array to concatenate.
  8077. * @param {...*} [values] The values to concatenate.
  8078. * @returns {Array} Returns the new concatenated array.
  8079. * @example
  8080. *
  8081. * var array = [1];
  8082. * var other = _.concat(array, 2, [3], [[4]]);
  8083. *
  8084. * console.log(other);
  8085. * // => [1, 2, 3, [4]]
  8086. *
  8087. * console.log(array);
  8088. * // => [1]
  8089. */
  8090. function concat() {
  8091. var length = arguments.length;
  8092. if (!length) {
  8093. return [];
  8094. }
  8095. var args = Array(length - 1),
  8096. array = arguments[0],
  8097. index = length;
  8098. while (index--) {
  8099. args[index - 1] = arguments[index];
  8100. }
  8101. return arrayPush(isArray(array) ? copyArray(array) : [array], baseFlatten(args, 1));
  8102. }
  8103. /**
  8104. * Creates an array of `array` values not included in the other given arrays
  8105. * using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
  8106. * for equality comparisons. The order and references of result values are
  8107. * determined by the first array.
  8108. *
  8109. * **Note:** Unlike `_.pullAll`, this method returns a new array.
  8110. *
  8111. * @static
  8112. * @memberOf _
  8113. * @since 0.1.0
  8114. * @category Array
  8115. * @param {Array} array The array to inspect.
  8116. * @param {...Array} [values] The values to exclude.
  8117. * @returns {Array} Returns the new array of filtered values.
  8118. * @see _.without, _.xor
  8119. * @example
  8120. *
  8121. * _.difference([2, 1], [2, 3]);
  8122. * // => [1]
  8123. */
  8124. var difference = baseRest(function(array, values) {
  8125. return isArrayLikeObject(array)
  8126. ? baseDifference(array, baseFlatten(values, 1, isArrayLikeObject, true))
  8127. : [];
  8128. });
  8129. /**
  8130. * This method is like `_.difference` except that it accepts `iteratee` which
  8131. * is invoked for each element of `array` and `values` to generate the criterion
  8132. * by which they're compared. The order and references of result values are
  8133. * determined by the first array. The iteratee is invoked with one argument:
  8134. * (value).
  8135. *
  8136. * **Note:** Unlike `_.pullAllBy`, this method returns a new array.
  8137. *
  8138. * @static
  8139. * @memberOf _
  8140. * @since 4.0.0
  8141. * @category Array
  8142. * @param {Array} array The array to inspect.
  8143. * @param {...Array} [values] The values to exclude.
  8144. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  8145. * @returns {Array} Returns the new array of filtered values.
  8146. * @example
  8147. *
  8148. * _.differenceBy([2.1, 1.2], [2.3, 3.4], Math.floor);
  8149. * // => [1.2]
  8150. *
  8151. * // The `_.property` iteratee shorthand.
  8152. * _.differenceBy([{ 'x': 2 }, { 'x': 1 }], [{ 'x': 1 }], 'x');
  8153. * // => [{ 'x': 2 }]
  8154. */
  8155. var differenceBy = baseRest(function(array, values) {
  8156. var iteratee = last(values);
  8157. if (isArrayLikeObject(iteratee)) {
  8158. iteratee = undefined;
  8159. }
  8160. return isArrayLikeObject(array)
  8161. ? baseDifference(array, baseFlatten(values, 1, isArrayLikeObject, true), getIteratee(iteratee, 2))
  8162. : [];
  8163. });
  8164. /**
  8165. * This method is like `_.difference` except that it accepts `comparator`
  8166. * which is invoked to compare elements of `array` to `values`. The order and
  8167. * references of result values are determined by the first array. The comparator
  8168. * is invoked with two arguments: (arrVal, othVal).
  8169. *
  8170. * **Note:** Unlike `_.pullAllWith`, this method returns a new array.
  8171. *
  8172. * @static
  8173. * @memberOf _
  8174. * @since 4.0.0
  8175. * @category Array
  8176. * @param {Array} array The array to inspect.
  8177. * @param {...Array} [values] The values to exclude.
  8178. * @param {Function} [comparator] The comparator invoked per element.
  8179. * @returns {Array} Returns the new array of filtered values.
  8180. * @example
  8181. *
  8182. * var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }];
  8183. *
  8184. * _.differenceWith(objects, [{ 'x': 1, 'y': 2 }], _.isEqual);
  8185. * // => [{ 'x': 2, 'y': 1 }]
  8186. */
  8187. var differenceWith = baseRest(function(array, values) {
  8188. var comparator = last(values);
  8189. if (isArrayLikeObject(comparator)) {
  8190. comparator = undefined;
  8191. }
  8192. return isArrayLikeObject(array)
  8193. ? baseDifference(array, baseFlatten(values, 1, isArrayLikeObject, true), undefined, comparator)
  8194. : [];
  8195. });
  8196. /**
  8197. * Creates a slice of `array` with `n` elements dropped from the beginning.
  8198. *
  8199. * @static
  8200. * @memberOf _
  8201. * @since 0.5.0
  8202. * @category Array
  8203. * @param {Array} array The array to query.
  8204. * @param {number} [n=1] The number of elements to drop.
  8205. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  8206. * @returns {Array} Returns the slice of `array`.
  8207. * @example
  8208. *
  8209. * _.drop([1, 2, 3]);
  8210. * // => [2, 3]
  8211. *
  8212. * _.drop([1, 2, 3], 2);
  8213. * // => [3]
  8214. *
  8215. * _.drop([1, 2, 3], 5);
  8216. * // => []
  8217. *
  8218. * _.drop([1, 2, 3], 0);
  8219. * // => [1, 2, 3]
  8220. */
  8221. function drop(array, n, guard) {
  8222. var length = array == null ? 0 : array.length;
  8223. if (!length) {
  8224. return [];
  8225. }
  8226. n = (guard || n === undefined) ? 1 : toInteger(n);
  8227. return baseSlice(array, n < 0 ? 0 : n, length);
  8228. }
  8229. /**
  8230. * Creates a slice of `array` with `n` elements dropped from the end.
  8231. *
  8232. * @static
  8233. * @memberOf _
  8234. * @since 3.0.0
  8235. * @category Array
  8236. * @param {Array} array The array to query.
  8237. * @param {number} [n=1] The number of elements to drop.
  8238. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  8239. * @returns {Array} Returns the slice of `array`.
  8240. * @example
  8241. *
  8242. * _.dropRight([1, 2, 3]);
  8243. * // => [1, 2]
  8244. *
  8245. * _.dropRight([1, 2, 3], 2);
  8246. * // => [1]
  8247. *
  8248. * _.dropRight([1, 2, 3], 5);
  8249. * // => []
  8250. *
  8251. * _.dropRight([1, 2, 3], 0);
  8252. * // => [1, 2, 3]
  8253. */
  8254. function dropRight(array, n, guard) {
  8255. var length = array == null ? 0 : array.length;
  8256. if (!length) {
  8257. return [];
  8258. }
  8259. n = (guard || n === undefined) ? 1 : toInteger(n);
  8260. n = length - n;
  8261. return baseSlice(array, 0, n < 0 ? 0 : n);
  8262. }
  8263. /**
  8264. * Creates a slice of `array` excluding elements dropped from the end.
  8265. * Elements are dropped until `predicate` returns falsey. The predicate is
  8266. * invoked with three arguments: (value, index, array).
  8267. *
  8268. * @static
  8269. * @memberOf _
  8270. * @since 3.0.0
  8271. * @category Array
  8272. * @param {Array} array The array to query.
  8273. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  8274. * @returns {Array} Returns the slice of `array`.
  8275. * @example
  8276. *
  8277. * var users = [
  8278. * { 'user': 'barney', 'active': true },
  8279. * { 'user': 'fred', 'active': false },
  8280. * { 'user': 'pebbles', 'active': false }
  8281. * ];
  8282. *
  8283. * _.dropRightWhile(users, function(o) { return !o.active; });
  8284. * // => objects for ['barney']
  8285. *
  8286. * // The `_.matches` iteratee shorthand.
  8287. * _.dropRightWhile(users, { 'user': 'pebbles', 'active': false });
  8288. * // => objects for ['barney', 'fred']
  8289. *
  8290. * // The `_.matchesProperty` iteratee shorthand.
  8291. * _.dropRightWhile(users, ['active', false]);
  8292. * // => objects for ['barney']
  8293. *
  8294. * // The `_.property` iteratee shorthand.
  8295. * _.dropRightWhile(users, 'active');
  8296. * // => objects for ['barney', 'fred', 'pebbles']
  8297. */
  8298. function dropRightWhile(array, predicate) {
  8299. return (array && array.length)
  8300. ? baseWhile(array, getIteratee(predicate, 3), true, true)
  8301. : [];
  8302. }
  8303. /**
  8304. * Creates a slice of `array` excluding elements dropped from the beginning.
  8305. * Elements are dropped until `predicate` returns falsey. The predicate is
  8306. * invoked with three arguments: (value, index, array).
  8307. *
  8308. * @static
  8309. * @memberOf _
  8310. * @since 3.0.0
  8311. * @category Array
  8312. * @param {Array} array The array to query.
  8313. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  8314. * @returns {Array} Returns the slice of `array`.
  8315. * @example
  8316. *
  8317. * var users = [
  8318. * { 'user': 'barney', 'active': false },
  8319. * { 'user': 'fred', 'active': false },
  8320. * { 'user': 'pebbles', 'active': true }
  8321. * ];
  8322. *
  8323. * _.dropWhile(users, function(o) { return !o.active; });
  8324. * // => objects for ['pebbles']
  8325. *
  8326. * // The `_.matches` iteratee shorthand.
  8327. * _.dropWhile(users, { 'user': 'barney', 'active': false });
  8328. * // => objects for ['fred', 'pebbles']
  8329. *
  8330. * // The `_.matchesProperty` iteratee shorthand.
  8331. * _.dropWhile(users, ['active', false]);
  8332. * // => objects for ['pebbles']
  8333. *
  8334. * // The `_.property` iteratee shorthand.
  8335. * _.dropWhile(users, 'active');
  8336. * // => objects for ['barney', 'fred', 'pebbles']
  8337. */
  8338. function dropWhile(array, predicate) {
  8339. return (array && array.length)
  8340. ? baseWhile(array, getIteratee(predicate, 3), true)
  8341. : [];
  8342. }
  8343. /**
  8344. * Fills elements of `array` with `value` from `start` up to, but not
  8345. * including, `end`.
  8346. *
  8347. * **Note:** This method mutates `array`.
  8348. *
  8349. * @static
  8350. * @memberOf _
  8351. * @since 3.2.0
  8352. * @category Array
  8353. * @param {Array} array The array to fill.
  8354. * @param {*} value The value to fill `array` with.
  8355. * @param {number} [start=0] The start position.
  8356. * @param {number} [end=array.length] The end position.
  8357. * @returns {Array} Returns `array`.
  8358. * @example
  8359. *
  8360. * var array = [1, 2, 3];
  8361. *
  8362. * _.fill(array, 'a');
  8363. * console.log(array);
  8364. * // => ['a', 'a', 'a']
  8365. *
  8366. * _.fill(Array(3), 2);
  8367. * // => [2, 2, 2]
  8368. *
  8369. * _.fill([4, 6, 8, 10], '*', 1, 3);
  8370. * // => [4, '*', '*', 10]
  8371. */
  8372. function fill(array, value, start, end) {
  8373. var length = array == null ? 0 : array.length;
  8374. if (!length) {
  8375. return [];
  8376. }
  8377. if (start && typeof start != 'number' && isIterateeCall(array, value, start)) {
  8378. start = 0;
  8379. end = length;
  8380. }
  8381. return baseFill(array, value, start, end);
  8382. }
  8383. /**
  8384. * This method is like `_.find` except that it returns the index of the first
  8385. * element `predicate` returns truthy for instead of the element itself.
  8386. *
  8387. * @static
  8388. * @memberOf _
  8389. * @since 1.1.0
  8390. * @category Array
  8391. * @param {Array} array The array to inspect.
  8392. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  8393. * @param {number} [fromIndex=0] The index to search from.
  8394. * @returns {number} Returns the index of the found element, else `-1`.
  8395. * @example
  8396. *
  8397. * var users = [
  8398. * { 'user': 'barney', 'active': false },
  8399. * { 'user': 'fred', 'active': false },
  8400. * { 'user': 'pebbles', 'active': true }
  8401. * ];
  8402. *
  8403. * _.findIndex(users, function(o) { return o.user == 'barney'; });
  8404. * // => 0
  8405. *
  8406. * // The `_.matches` iteratee shorthand.
  8407. * _.findIndex(users, { 'user': 'fred', 'active': false });
  8408. * // => 1
  8409. *
  8410. * // The `_.matchesProperty` iteratee shorthand.
  8411. * _.findIndex(users, ['active', false]);
  8412. * // => 0
  8413. *
  8414. * // The `_.property` iteratee shorthand.
  8415. * _.findIndex(users, 'active');
  8416. * // => 2
  8417. */
  8418. function findIndex(array, predicate, fromIndex) {
  8419. var length = array == null ? 0 : array.length;
  8420. if (!length) {
  8421. return -1;
  8422. }
  8423. var index = fromIndex == null ? 0 : toInteger(fromIndex);
  8424. if (index < 0) {
  8425. index = nativeMax(length + index, 0);
  8426. }
  8427. return baseFindIndex(array, getIteratee(predicate, 3), index);
  8428. }
  8429. /**
  8430. * This method is like `_.findIndex` except that it iterates over elements
  8431. * of `collection` from right to left.
  8432. *
  8433. * @static
  8434. * @memberOf _
  8435. * @since 2.0.0
  8436. * @category Array
  8437. * @param {Array} array The array to inspect.
  8438. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  8439. * @param {number} [fromIndex=array.length-1] The index to search from.
  8440. * @returns {number} Returns the index of the found element, else `-1`.
  8441. * @example
  8442. *
  8443. * var users = [
  8444. * { 'user': 'barney', 'active': true },
  8445. * { 'user': 'fred', 'active': false },
  8446. * { 'user': 'pebbles', 'active': false }
  8447. * ];
  8448. *
  8449. * _.findLastIndex(users, function(o) { return o.user == 'pebbles'; });
  8450. * // => 2
  8451. *
  8452. * // The `_.matches` iteratee shorthand.
  8453. * _.findLastIndex(users, { 'user': 'barney', 'active': true });
  8454. * // => 0
  8455. *
  8456. * // The `_.matchesProperty` iteratee shorthand.
  8457. * _.findLastIndex(users, ['active', false]);
  8458. * // => 2
  8459. *
  8460. * // The `_.property` iteratee shorthand.
  8461. * _.findLastIndex(users, 'active');
  8462. * // => 0
  8463. */
  8464. function findLastIndex(array, predicate, fromIndex) {
  8465. var length = array == null ? 0 : array.length;
  8466. if (!length) {
  8467. return -1;
  8468. }
  8469. var index = length - 1;
  8470. if (fromIndex !== undefined) {
  8471. index = toInteger(fromIndex);
  8472. index = fromIndex < 0
  8473. ? nativeMax(length + index, 0)
  8474. : nativeMin(index, length - 1);
  8475. }
  8476. return baseFindIndex(array, getIteratee(predicate, 3), index, true);
  8477. }
  8478. /**
  8479. * Flattens `array` a single level deep.
  8480. *
  8481. * @static
  8482. * @memberOf _
  8483. * @since 0.1.0
  8484. * @category Array
  8485. * @param {Array} array The array to flatten.
  8486. * @returns {Array} Returns the new flattened array.
  8487. * @example
  8488. *
  8489. * _.flatten([1, [2, [3, [4]], 5]]);
  8490. * // => [1, 2, [3, [4]], 5]
  8491. */
  8492. function flatten(array) {
  8493. var length = array == null ? 0 : array.length;
  8494. return length ? baseFlatten(array, 1) : [];
  8495. }
  8496. /**
  8497. * Recursively flattens `array`.
  8498. *
  8499. * @static
  8500. * @memberOf _
  8501. * @since 3.0.0
  8502. * @category Array
  8503. * @param {Array} array The array to flatten.
  8504. * @returns {Array} Returns the new flattened array.
  8505. * @example
  8506. *
  8507. * _.flattenDeep([1, [2, [3, [4]], 5]]);
  8508. * // => [1, 2, 3, 4, 5]
  8509. */
  8510. function flattenDeep(array) {
  8511. var length = array == null ? 0 : array.length;
  8512. return length ? baseFlatten(array, INFINITY) : [];
  8513. }
  8514. /**
  8515. * Recursively flatten `array` up to `depth` times.
  8516. *
  8517. * @static
  8518. * @memberOf _
  8519. * @since 4.4.0
  8520. * @category Array
  8521. * @param {Array} array The array to flatten.
  8522. * @param {number} [depth=1] The maximum recursion depth.
  8523. * @returns {Array} Returns the new flattened array.
  8524. * @example
  8525. *
  8526. * var array = [1, [2, [3, [4]], 5]];
  8527. *
  8528. * _.flattenDepth(array, 1);
  8529. * // => [1, 2, [3, [4]], 5]
  8530. *
  8531. * _.flattenDepth(array, 2);
  8532. * // => [1, 2, 3, [4], 5]
  8533. */
  8534. function flattenDepth(array, depth) {
  8535. var length = array == null ? 0 : array.length;
  8536. if (!length) {
  8537. return [];
  8538. }
  8539. depth = depth === undefined ? 1 : toInteger(depth);
  8540. return baseFlatten(array, depth);
  8541. }
  8542. /**
  8543. * The inverse of `_.toPairs`; this method returns an object composed
  8544. * from key-value `pairs`.
  8545. *
  8546. * @static
  8547. * @memberOf _
  8548. * @since 4.0.0
  8549. * @category Array
  8550. * @param {Array} pairs The key-value pairs.
  8551. * @returns {Object} Returns the new object.
  8552. * @example
  8553. *
  8554. * _.fromPairs([['a', 1], ['b', 2]]);
  8555. * // => { 'a': 1, 'b': 2 }
  8556. */
  8557. function fromPairs(pairs) {
  8558. var index = -1,
  8559. length = pairs == null ? 0 : pairs.length,
  8560. result = {};
  8561. while (++index < length) {
  8562. var pair = pairs[index];
  8563. result[pair[0]] = pair[1];
  8564. }
  8565. return result;
  8566. }
  8567. /**
  8568. * Gets the first element of `array`.
  8569. *
  8570. * @static
  8571. * @memberOf _
  8572. * @since 0.1.0
  8573. * @alias first
  8574. * @category Array
  8575. * @param {Array} array The array to query.
  8576. * @returns {*} Returns the first element of `array`.
  8577. * @example
  8578. *
  8579. * _.head([1, 2, 3]);
  8580. * // => 1
  8581. *
  8582. * _.head([]);
  8583. * // => undefined
  8584. */
  8585. function head(array) {
  8586. return (array && array.length) ? array[0] : undefined;
  8587. }
  8588. /**
  8589. * Gets the index at which the first occurrence of `value` is found in `array`
  8590. * using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
  8591. * for equality comparisons. If `fromIndex` is negative, it's used as the
  8592. * offset from the end of `array`.
  8593. *
  8594. * @static
  8595. * @memberOf _
  8596. * @since 0.1.0
  8597. * @category Array
  8598. * @param {Array} array The array to inspect.
  8599. * @param {*} value The value to search for.
  8600. * @param {number} [fromIndex=0] The index to search from.
  8601. * @returns {number} Returns the index of the matched value, else `-1`.
  8602. * @example
  8603. *
  8604. * _.indexOf([1, 2, 1, 2], 2);
  8605. * // => 1
  8606. *
  8607. * // Search from the `fromIndex`.
  8608. * _.indexOf([1, 2, 1, 2], 2, 2);
  8609. * // => 3
  8610. */
  8611. function indexOf(array, value, fromIndex) {
  8612. var length = array == null ? 0 : array.length;
  8613. if (!length) {
  8614. return -1;
  8615. }
  8616. var index = fromIndex == null ? 0 : toInteger(fromIndex);
  8617. if (index < 0) {
  8618. index = nativeMax(length + index, 0);
  8619. }
  8620. return baseIndexOf(array, value, index);
  8621. }
  8622. /**
  8623. * Gets all but the last element of `array`.
  8624. *
  8625. * @static
  8626. * @memberOf _
  8627. * @since 0.1.0
  8628. * @category Array
  8629. * @param {Array} array The array to query.
  8630. * @returns {Array} Returns the slice of `array`.
  8631. * @example
  8632. *
  8633. * _.initial([1, 2, 3]);
  8634. * // => [1, 2]
  8635. */
  8636. function initial(array) {
  8637. var length = array == null ? 0 : array.length;
  8638. return length ? baseSlice(array, 0, -1) : [];
  8639. }
  8640. /**
  8641. * Creates an array of unique values that are included in all given arrays
  8642. * using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
  8643. * for equality comparisons. The order and references of result values are
  8644. * determined by the first array.
  8645. *
  8646. * @static
  8647. * @memberOf _
  8648. * @since 0.1.0
  8649. * @category Array
  8650. * @param {...Array} [arrays] The arrays to inspect.
  8651. * @returns {Array} Returns the new array of intersecting values.
  8652. * @example
  8653. *
  8654. * _.intersection([2, 1], [2, 3]);
  8655. * // => [2]
  8656. */
  8657. var intersection = baseRest(function(arrays) {
  8658. var mapped = arrayMap(arrays, castArrayLikeObject);
  8659. return (mapped.length && mapped[0] === arrays[0])
  8660. ? baseIntersection(mapped)
  8661. : [];
  8662. });
  8663. /**
  8664. * This method is like `_.intersection` except that it accepts `iteratee`
  8665. * which is invoked for each element of each `arrays` to generate the criterion
  8666. * by which they're compared. The order and references of result values are
  8667. * determined by the first array. The iteratee is invoked with one argument:
  8668. * (value).
  8669. *
  8670. * @static
  8671. * @memberOf _
  8672. * @since 4.0.0
  8673. * @category Array
  8674. * @param {...Array} [arrays] The arrays to inspect.
  8675. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  8676. * @returns {Array} Returns the new array of intersecting values.
  8677. * @example
  8678. *
  8679. * _.intersectionBy([2.1, 1.2], [2.3, 3.4], Math.floor);
  8680. * // => [2.1]
  8681. *
  8682. * // The `_.property` iteratee shorthand.
  8683. * _.intersectionBy([{ 'x': 1 }], [{ 'x': 2 }, { 'x': 1 }], 'x');
  8684. * // => [{ 'x': 1 }]
  8685. */
  8686. var intersectionBy = baseRest(function(arrays) {
  8687. var iteratee = last(arrays),
  8688. mapped = arrayMap(arrays, castArrayLikeObject);
  8689. if (iteratee === last(mapped)) {
  8690. iteratee = undefined;
  8691. } else {
  8692. mapped.pop();
  8693. }
  8694. return (mapped.length && mapped[0] === arrays[0])
  8695. ? baseIntersection(mapped, getIteratee(iteratee, 2))
  8696. : [];
  8697. });
  8698. /**
  8699. * This method is like `_.intersection` except that it accepts `comparator`
  8700. * which is invoked to compare elements of `arrays`. The order and references
  8701. * of result values are determined by the first array. The comparator is
  8702. * invoked with two arguments: (arrVal, othVal).
  8703. *
  8704. * @static
  8705. * @memberOf _
  8706. * @since 4.0.0
  8707. * @category Array
  8708. * @param {...Array} [arrays] The arrays to inspect.
  8709. * @param {Function} [comparator] The comparator invoked per element.
  8710. * @returns {Array} Returns the new array of intersecting values.
  8711. * @example
  8712. *
  8713. * var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }];
  8714. * var others = [{ 'x': 1, 'y': 1 }, { 'x': 1, 'y': 2 }];
  8715. *
  8716. * _.intersectionWith(objects, others, _.isEqual);
  8717. * // => [{ 'x': 1, 'y': 2 }]
  8718. */
  8719. var intersectionWith = baseRest(function(arrays) {
  8720. var comparator = last(arrays),
  8721. mapped = arrayMap(arrays, castArrayLikeObject);
  8722. comparator = typeof comparator == 'function' ? comparator : undefined;
  8723. if (comparator) {
  8724. mapped.pop();
  8725. }
  8726. return (mapped.length && mapped[0] === arrays[0])
  8727. ? baseIntersection(mapped, undefined, comparator)
  8728. : [];
  8729. });
  8730. /**
  8731. * Converts all elements in `array` into a string separated by `separator`.
  8732. *
  8733. * @static
  8734. * @memberOf _
  8735. * @since 4.0.0
  8736. * @category Array
  8737. * @param {Array} array The array to convert.
  8738. * @param {string} [separator=','] The element separator.
  8739. * @returns {string} Returns the joined string.
  8740. * @example
  8741. *
  8742. * _.join(['a', 'b', 'c'], '~');
  8743. * // => 'a~b~c'
  8744. */
  8745. function join(array, separator) {
  8746. return array == null ? '' : nativeJoin.call(array, separator);
  8747. }
  8748. /**
  8749. * Gets the last element of `array`.
  8750. *
  8751. * @static
  8752. * @memberOf _
  8753. * @since 0.1.0
  8754. * @category Array
  8755. * @param {Array} array The array to query.
  8756. * @returns {*} Returns the last element of `array`.
  8757. * @example
  8758. *
  8759. * _.last([1, 2, 3]);
  8760. * // => 3
  8761. */
  8762. function last(array) {
  8763. var length = array == null ? 0 : array.length;
  8764. return length ? array[length - 1] : undefined;
  8765. }
  8766. /**
  8767. * This method is like `_.indexOf` except that it iterates over elements of
  8768. * `array` from right to left.
  8769. *
  8770. * @static
  8771. * @memberOf _
  8772. * @since 0.1.0
  8773. * @category Array
  8774. * @param {Array} array The array to inspect.
  8775. * @param {*} value The value to search for.
  8776. * @param {number} [fromIndex=array.length-1] The index to search from.
  8777. * @returns {number} Returns the index of the matched value, else `-1`.
  8778. * @example
  8779. *
  8780. * _.lastIndexOf([1, 2, 1, 2], 2);
  8781. * // => 3
  8782. *
  8783. * // Search from the `fromIndex`.
  8784. * _.lastIndexOf([1, 2, 1, 2], 2, 2);
  8785. * // => 1
  8786. */
  8787. function lastIndexOf(array, value, fromIndex) {
  8788. var length = array == null ? 0 : array.length;
  8789. if (!length) {
  8790. return -1;
  8791. }
  8792. var index = length;
  8793. if (fromIndex !== undefined) {
  8794. index = toInteger(fromIndex);
  8795. index = index < 0 ? nativeMax(length + index, 0) : nativeMin(index, length - 1);
  8796. }
  8797. return value === value
  8798. ? strictLastIndexOf(array, value, index)
  8799. : baseFindIndex(array, baseIsNaN, index, true);
  8800. }
  8801. /**
  8802. * Gets the element at index `n` of `array`. If `n` is negative, the nth
  8803. * element from the end is returned.
  8804. *
  8805. * @static
  8806. * @memberOf _
  8807. * @since 4.11.0
  8808. * @category Array
  8809. * @param {Array} array The array to query.
  8810. * @param {number} [n=0] The index of the element to return.
  8811. * @returns {*} Returns the nth element of `array`.
  8812. * @example
  8813. *
  8814. * var array = ['a', 'b', 'c', 'd'];
  8815. *
  8816. * _.nth(array, 1);
  8817. * // => 'b'
  8818. *
  8819. * _.nth(array, -2);
  8820. * // => 'c';
  8821. */
  8822. function nth(array, n) {
  8823. return (array && array.length) ? baseNth(array, toInteger(n)) : undefined;
  8824. }
  8825. /**
  8826. * Removes all given values from `array` using
  8827. * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
  8828. * for equality comparisons.
  8829. *
  8830. * **Note:** Unlike `_.without`, this method mutates `array`. Use `_.remove`
  8831. * to remove elements from an array by predicate.
  8832. *
  8833. * @static
  8834. * @memberOf _
  8835. * @since 2.0.0
  8836. * @category Array
  8837. * @param {Array} array The array to modify.
  8838. * @param {...*} [values] The values to remove.
  8839. * @returns {Array} Returns `array`.
  8840. * @example
  8841. *
  8842. * var array = ['a', 'b', 'c', 'a', 'b', 'c'];
  8843. *
  8844. * _.pull(array, 'a', 'c');
  8845. * console.log(array);
  8846. * // => ['b', 'b']
  8847. */
  8848. var pull = baseRest(pullAll);
  8849. /**
  8850. * This method is like `_.pull` except that it accepts an array of values to remove.
  8851. *
  8852. * **Note:** Unlike `_.difference`, this method mutates `array`.
  8853. *
  8854. * @static
  8855. * @memberOf _
  8856. * @since 4.0.0
  8857. * @category Array
  8858. * @param {Array} array The array to modify.
  8859. * @param {Array} values The values to remove.
  8860. * @returns {Array} Returns `array`.
  8861. * @example
  8862. *
  8863. * var array = ['a', 'b', 'c', 'a', 'b', 'c'];
  8864. *
  8865. * _.pullAll(array, ['a', 'c']);
  8866. * console.log(array);
  8867. * // => ['b', 'b']
  8868. */
  8869. function pullAll(array, values) {
  8870. return (array && array.length && values && values.length)
  8871. ? basePullAll(array, values)
  8872. : array;
  8873. }
  8874. /**
  8875. * This method is like `_.pullAll` except that it accepts `iteratee` which is
  8876. * invoked for each element of `array` and `values` to generate the criterion
  8877. * by which they're compared. The iteratee is invoked with one argument: (value).
  8878. *
  8879. * **Note:** Unlike `_.differenceBy`, this method mutates `array`.
  8880. *
  8881. * @static
  8882. * @memberOf _
  8883. * @since 4.0.0
  8884. * @category Array
  8885. * @param {Array} array The array to modify.
  8886. * @param {Array} values The values to remove.
  8887. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  8888. * @returns {Array} Returns `array`.
  8889. * @example
  8890. *
  8891. * var array = [{ 'x': 1 }, { 'x': 2 }, { 'x': 3 }, { 'x': 1 }];
  8892. *
  8893. * _.pullAllBy(array, [{ 'x': 1 }, { 'x': 3 }], 'x');
  8894. * console.log(array);
  8895. * // => [{ 'x': 2 }]
  8896. */
  8897. function pullAllBy(array, values, iteratee) {
  8898. return (array && array.length && values && values.length)
  8899. ? basePullAll(array, values, getIteratee(iteratee, 2))
  8900. : array;
  8901. }
  8902. /**
  8903. * This method is like `_.pullAll` except that it accepts `comparator` which
  8904. * is invoked to compare elements of `array` to `values`. The comparator is
  8905. * invoked with two arguments: (arrVal, othVal).
  8906. *
  8907. * **Note:** Unlike `_.differenceWith`, this method mutates `array`.
  8908. *
  8909. * @static
  8910. * @memberOf _
  8911. * @since 4.6.0
  8912. * @category Array
  8913. * @param {Array} array The array to modify.
  8914. * @param {Array} values The values to remove.
  8915. * @param {Function} [comparator] The comparator invoked per element.
  8916. * @returns {Array} Returns `array`.
  8917. * @example
  8918. *
  8919. * var array = [{ 'x': 1, 'y': 2 }, { 'x': 3, 'y': 4 }, { 'x': 5, 'y': 6 }];
  8920. *
  8921. * _.pullAllWith(array, [{ 'x': 3, 'y': 4 }], _.isEqual);
  8922. * console.log(array);
  8923. * // => [{ 'x': 1, 'y': 2 }, { 'x': 5, 'y': 6 }]
  8924. */
  8925. function pullAllWith(array, values, comparator) {
  8926. return (array && array.length && values && values.length)
  8927. ? basePullAll(array, values, undefined, comparator)
  8928. : array;
  8929. }
  8930. /**
  8931. * Removes elements from `array` corresponding to `indexes` and returns an
  8932. * array of removed elements.
  8933. *
  8934. * **Note:** Unlike `_.at`, this method mutates `array`.
  8935. *
  8936. * @static
  8937. * @memberOf _
  8938. * @since 3.0.0
  8939. * @category Array
  8940. * @param {Array} array The array to modify.
  8941. * @param {...(number|number[])} [indexes] The indexes of elements to remove.
  8942. * @returns {Array} Returns the new array of removed elements.
  8943. * @example
  8944. *
  8945. * var array = ['a', 'b', 'c', 'd'];
  8946. * var pulled = _.pullAt(array, [1, 3]);
  8947. *
  8948. * console.log(array);
  8949. * // => ['a', 'c']
  8950. *
  8951. * console.log(pulled);
  8952. * // => ['b', 'd']
  8953. */
  8954. var pullAt = flatRest(function(array, indexes) {
  8955. var length = array == null ? 0 : array.length,
  8956. result = baseAt(array, indexes);
  8957. basePullAt(array, arrayMap(indexes, function(index) {
  8958. return isIndex(index, length) ? +index : index;
  8959. }).sort(compareAscending));
  8960. return result;
  8961. });
  8962. /**
  8963. * Removes all elements from `array` that `predicate` returns truthy for
  8964. * and returns an array of the removed elements. The predicate is invoked
  8965. * with three arguments: (value, index, array).
  8966. *
  8967. * **Note:** Unlike `_.filter`, this method mutates `array`. Use `_.pull`
  8968. * to pull elements from an array by value.
  8969. *
  8970. * @static
  8971. * @memberOf _
  8972. * @since 2.0.0
  8973. * @category Array
  8974. * @param {Array} array The array to modify.
  8975. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  8976. * @returns {Array} Returns the new array of removed elements.
  8977. * @example
  8978. *
  8979. * var array = [1, 2, 3, 4];
  8980. * var evens = _.remove(array, function(n) {
  8981. * return n % 2 == 0;
  8982. * });
  8983. *
  8984. * console.log(array);
  8985. * // => [1, 3]
  8986. *
  8987. * console.log(evens);
  8988. * // => [2, 4]
  8989. */
  8990. function remove(array, predicate) {
  8991. var result = [];
  8992. if (!(array && array.length)) {
  8993. return result;
  8994. }
  8995. var index = -1,
  8996. indexes = [],
  8997. length = array.length;
  8998. predicate = getIteratee(predicate, 3);
  8999. while (++index < length) {
  9000. var value = array[index];
  9001. if (predicate(value, index, array)) {
  9002. result.push(value);
  9003. indexes.push(index);
  9004. }
  9005. }
  9006. basePullAt(array, indexes);
  9007. return result;
  9008. }
  9009. /**
  9010. * Reverses `array` so that the first element becomes the last, the second
  9011. * element becomes the second to last, and so on.
  9012. *
  9013. * **Note:** This method mutates `array` and is based on
  9014. * [`Array#reverse`](https://mdn.io/Array/reverse).
  9015. *
  9016. * @static
  9017. * @memberOf _
  9018. * @since 4.0.0
  9019. * @category Array
  9020. * @param {Array} array The array to modify.
  9021. * @returns {Array} Returns `array`.
  9022. * @example
  9023. *
  9024. * var array = [1, 2, 3];
  9025. *
  9026. * _.reverse(array);
  9027. * // => [3, 2, 1]
  9028. *
  9029. * console.log(array);
  9030. * // => [3, 2, 1]
  9031. */
  9032. function reverse(array) {
  9033. return array == null ? array : nativeReverse.call(array);
  9034. }
  9035. /**
  9036. * Creates a slice of `array` from `start` up to, but not including, `end`.
  9037. *
  9038. * **Note:** This method is used instead of
  9039. * [`Array#slice`](https://mdn.io/Array/slice) to ensure dense arrays are
  9040. * returned.
  9041. *
  9042. * @static
  9043. * @memberOf _
  9044. * @since 3.0.0
  9045. * @category Array
  9046. * @param {Array} array The array to slice.
  9047. * @param {number} [start=0] The start position.
  9048. * @param {number} [end=array.length] The end position.
  9049. * @returns {Array} Returns the slice of `array`.
  9050. */
  9051. function slice(array, start, end) {
  9052. var length = array == null ? 0 : array.length;
  9053. if (!length) {
  9054. return [];
  9055. }
  9056. if (end && typeof end != 'number' && isIterateeCall(array, start, end)) {
  9057. start = 0;
  9058. end = length;
  9059. }
  9060. else {
  9061. start = start == null ? 0 : toInteger(start);
  9062. end = end === undefined ? length : toInteger(end);
  9063. }
  9064. return baseSlice(array, start, end);
  9065. }
  9066. /**
  9067. * Uses a binary search to determine the lowest index at which `value`
  9068. * should be inserted into `array` in order to maintain its sort order.
  9069. *
  9070. * @static
  9071. * @memberOf _
  9072. * @since 0.1.0
  9073. * @category Array
  9074. * @param {Array} array The sorted array to inspect.
  9075. * @param {*} value The value to evaluate.
  9076. * @returns {number} Returns the index at which `value` should be inserted
  9077. * into `array`.
  9078. * @example
  9079. *
  9080. * _.sortedIndex([30, 50], 40);
  9081. * // => 1
  9082. */
  9083. function sortedIndex(array, value) {
  9084. return baseSortedIndex(array, value);
  9085. }
  9086. /**
  9087. * This method is like `_.sortedIndex` except that it accepts `iteratee`
  9088. * which is invoked for `value` and each element of `array` to compute their
  9089. * sort ranking. The iteratee is invoked with one argument: (value).
  9090. *
  9091. * @static
  9092. * @memberOf _
  9093. * @since 4.0.0
  9094. * @category Array
  9095. * @param {Array} array The sorted array to inspect.
  9096. * @param {*} value The value to evaluate.
  9097. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  9098. * @returns {number} Returns the index at which `value` should be inserted
  9099. * into `array`.
  9100. * @example
  9101. *
  9102. * var objects = [{ 'x': 4 }, { 'x': 5 }];
  9103. *
  9104. * _.sortedIndexBy(objects, { 'x': 4 }, function(o) { return o.x; });
  9105. * // => 0
  9106. *
  9107. * // The `_.property` iteratee shorthand.
  9108. * _.sortedIndexBy(objects, { 'x': 4 }, 'x');
  9109. * // => 0
  9110. */
  9111. function sortedIndexBy(array, value, iteratee) {
  9112. return baseSortedIndexBy(array, value, getIteratee(iteratee, 2));
  9113. }
  9114. /**
  9115. * This method is like `_.indexOf` except that it performs a binary
  9116. * search on a sorted `array`.
  9117. *
  9118. * @static
  9119. * @memberOf _
  9120. * @since 4.0.0
  9121. * @category Array
  9122. * @param {Array} array The array to inspect.
  9123. * @param {*} value The value to search for.
  9124. * @returns {number} Returns the index of the matched value, else `-1`.
  9125. * @example
  9126. *
  9127. * _.sortedIndexOf([4, 5, 5, 5, 6], 5);
  9128. * // => 1
  9129. */
  9130. function sortedIndexOf(array, value) {
  9131. var length = array == null ? 0 : array.length;
  9132. if (length) {
  9133. var index = baseSortedIndex(array, value);
  9134. if (index < length && eq(array[index], value)) {
  9135. return index;
  9136. }
  9137. }
  9138. return -1;
  9139. }
  9140. /**
  9141. * This method is like `_.sortedIndex` except that it returns the highest
  9142. * index at which `value` should be inserted into `array` in order to
  9143. * maintain its sort order.
  9144. *
  9145. * @static
  9146. * @memberOf _
  9147. * @since 3.0.0
  9148. * @category Array
  9149. * @param {Array} array The sorted array to inspect.
  9150. * @param {*} value The value to evaluate.
  9151. * @returns {number} Returns the index at which `value` should be inserted
  9152. * into `array`.
  9153. * @example
  9154. *
  9155. * _.sortedLastIndex([4, 5, 5, 5, 6], 5);
  9156. * // => 4
  9157. */
  9158. function sortedLastIndex(array, value) {
  9159. return baseSortedIndex(array, value, true);
  9160. }
  9161. /**
  9162. * This method is like `_.sortedLastIndex` except that it accepts `iteratee`
  9163. * which is invoked for `value` and each element of `array` to compute their
  9164. * sort ranking. The iteratee is invoked with one argument: (value).
  9165. *
  9166. * @static
  9167. * @memberOf _
  9168. * @since 4.0.0
  9169. * @category Array
  9170. * @param {Array} array The sorted array to inspect.
  9171. * @param {*} value The value to evaluate.
  9172. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  9173. * @returns {number} Returns the index at which `value` should be inserted
  9174. * into `array`.
  9175. * @example
  9176. *
  9177. * var objects = [{ 'x': 4 }, { 'x': 5 }];
  9178. *
  9179. * _.sortedLastIndexBy(objects, { 'x': 4 }, function(o) { return o.x; });
  9180. * // => 1
  9181. *
  9182. * // The `_.property` iteratee shorthand.
  9183. * _.sortedLastIndexBy(objects, { 'x': 4 }, 'x');
  9184. * // => 1
  9185. */
  9186. function sortedLastIndexBy(array, value, iteratee) {
  9187. return baseSortedIndexBy(array, value, getIteratee(iteratee, 2), true);
  9188. }
  9189. /**
  9190. * This method is like `_.lastIndexOf` except that it performs a binary
  9191. * search on a sorted `array`.
  9192. *
  9193. * @static
  9194. * @memberOf _
  9195. * @since 4.0.0
  9196. * @category Array
  9197. * @param {Array} array The array to inspect.
  9198. * @param {*} value The value to search for.
  9199. * @returns {number} Returns the index of the matched value, else `-1`.
  9200. * @example
  9201. *
  9202. * _.sortedLastIndexOf([4, 5, 5, 5, 6], 5);
  9203. * // => 3
  9204. */
  9205. function sortedLastIndexOf(array, value) {
  9206. var length = array == null ? 0 : array.length;
  9207. if (length) {
  9208. var index = baseSortedIndex(array, value, true) - 1;
  9209. if (eq(array[index], value)) {
  9210. return index;
  9211. }
  9212. }
  9213. return -1;
  9214. }
  9215. /**
  9216. * This method is like `_.uniq` except that it's designed and optimized
  9217. * for sorted arrays.
  9218. *
  9219. * @static
  9220. * @memberOf _
  9221. * @since 4.0.0
  9222. * @category Array
  9223. * @param {Array} array The array to inspect.
  9224. * @returns {Array} Returns the new duplicate free array.
  9225. * @example
  9226. *
  9227. * _.sortedUniq([1, 1, 2]);
  9228. * // => [1, 2]
  9229. */
  9230. function sortedUniq(array) {
  9231. return (array && array.length)
  9232. ? baseSortedUniq(array)
  9233. : [];
  9234. }
  9235. /**
  9236. * This method is like `_.uniqBy` except that it's designed and optimized
  9237. * for sorted arrays.
  9238. *
  9239. * @static
  9240. * @memberOf _
  9241. * @since 4.0.0
  9242. * @category Array
  9243. * @param {Array} array The array to inspect.
  9244. * @param {Function} [iteratee] The iteratee invoked per element.
  9245. * @returns {Array} Returns the new duplicate free array.
  9246. * @example
  9247. *
  9248. * _.sortedUniqBy([1.1, 1.2, 2.3, 2.4], Math.floor);
  9249. * // => [1.1, 2.3]
  9250. */
  9251. function sortedUniqBy(array, iteratee) {
  9252. return (array && array.length)
  9253. ? baseSortedUniq(array, getIteratee(iteratee, 2))
  9254. : [];
  9255. }
  9256. /**
  9257. * Gets all but the first element of `array`.
  9258. *
  9259. * @static
  9260. * @memberOf _
  9261. * @since 4.0.0
  9262. * @category Array
  9263. * @param {Array} array The array to query.
  9264. * @returns {Array} Returns the slice of `array`.
  9265. * @example
  9266. *
  9267. * _.tail([1, 2, 3]);
  9268. * // => [2, 3]
  9269. */
  9270. function tail(array) {
  9271. var length = array == null ? 0 : array.length;
  9272. return length ? baseSlice(array, 1, length) : [];
  9273. }
  9274. /**
  9275. * Creates a slice of `array` with `n` elements taken from the beginning.
  9276. *
  9277. * @static
  9278. * @memberOf _
  9279. * @since 0.1.0
  9280. * @category Array
  9281. * @param {Array} array The array to query.
  9282. * @param {number} [n=1] The number of elements to take.
  9283. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  9284. * @returns {Array} Returns the slice of `array`.
  9285. * @example
  9286. *
  9287. * _.take([1, 2, 3]);
  9288. * // => [1]
  9289. *
  9290. * _.take([1, 2, 3], 2);
  9291. * // => [1, 2]
  9292. *
  9293. * _.take([1, 2, 3], 5);
  9294. * // => [1, 2, 3]
  9295. *
  9296. * _.take([1, 2, 3], 0);
  9297. * // => []
  9298. */
  9299. function take(array, n, guard) {
  9300. if (!(array && array.length)) {
  9301. return [];
  9302. }
  9303. n = (guard || n === undefined) ? 1 : toInteger(n);
  9304. return baseSlice(array, 0, n < 0 ? 0 : n);
  9305. }
  9306. /**
  9307. * Creates a slice of `array` with `n` elements taken from the end.
  9308. *
  9309. * @static
  9310. * @memberOf _
  9311. * @since 3.0.0
  9312. * @category Array
  9313. * @param {Array} array The array to query.
  9314. * @param {number} [n=1] The number of elements to take.
  9315. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  9316. * @returns {Array} Returns the slice of `array`.
  9317. * @example
  9318. *
  9319. * _.takeRight([1, 2, 3]);
  9320. * // => [3]
  9321. *
  9322. * _.takeRight([1, 2, 3], 2);
  9323. * // => [2, 3]
  9324. *
  9325. * _.takeRight([1, 2, 3], 5);
  9326. * // => [1, 2, 3]
  9327. *
  9328. * _.takeRight([1, 2, 3], 0);
  9329. * // => []
  9330. */
  9331. function takeRight(array, n, guard) {
  9332. var length = array == null ? 0 : array.length;
  9333. if (!length) {
  9334. return [];
  9335. }
  9336. n = (guard || n === undefined) ? 1 : toInteger(n);
  9337. n = length - n;
  9338. return baseSlice(array, n < 0 ? 0 : n, length);
  9339. }
  9340. /**
  9341. * Creates a slice of `array` with elements taken from the end. Elements are
  9342. * taken until `predicate` returns falsey. The predicate is invoked with
  9343. * three arguments: (value, index, array).
  9344. *
  9345. * @static
  9346. * @memberOf _
  9347. * @since 3.0.0
  9348. * @category Array
  9349. * @param {Array} array The array to query.
  9350. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  9351. * @returns {Array} Returns the slice of `array`.
  9352. * @example
  9353. *
  9354. * var users = [
  9355. * { 'user': 'barney', 'active': true },
  9356. * { 'user': 'fred', 'active': false },
  9357. * { 'user': 'pebbles', 'active': false }
  9358. * ];
  9359. *
  9360. * _.takeRightWhile(users, function(o) { return !o.active; });
  9361. * // => objects for ['fred', 'pebbles']
  9362. *
  9363. * // The `_.matches` iteratee shorthand.
  9364. * _.takeRightWhile(users, { 'user': 'pebbles', 'active': false });
  9365. * // => objects for ['pebbles']
  9366. *
  9367. * // The `_.matchesProperty` iteratee shorthand.
  9368. * _.takeRightWhile(users, ['active', false]);
  9369. * // => objects for ['fred', 'pebbles']
  9370. *
  9371. * // The `_.property` iteratee shorthand.
  9372. * _.takeRightWhile(users, 'active');
  9373. * // => []
  9374. */
  9375. function takeRightWhile(array, predicate) {
  9376. return (array && array.length)
  9377. ? baseWhile(array, getIteratee(predicate, 3), false, true)
  9378. : [];
  9379. }
  9380. /**
  9381. * Creates a slice of `array` with elements taken from the beginning. Elements
  9382. * are taken until `predicate` returns falsey. The predicate is invoked with
  9383. * three arguments: (value, index, array).
  9384. *
  9385. * @static
  9386. * @memberOf _
  9387. * @since 3.0.0
  9388. * @category Array
  9389. * @param {Array} array The array to query.
  9390. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  9391. * @returns {Array} Returns the slice of `array`.
  9392. * @example
  9393. *
  9394. * var users = [
  9395. * { 'user': 'barney', 'active': false },
  9396. * { 'user': 'fred', 'active': false },
  9397. * { 'user': 'pebbles', 'active': true }
  9398. * ];
  9399. *
  9400. * _.takeWhile(users, function(o) { return !o.active; });
  9401. * // => objects for ['barney', 'fred']
  9402. *
  9403. * // The `_.matches` iteratee shorthand.
  9404. * _.takeWhile(users, { 'user': 'barney', 'active': false });
  9405. * // => objects for ['barney']
  9406. *
  9407. * // The `_.matchesProperty` iteratee shorthand.
  9408. * _.takeWhile(users, ['active', false]);
  9409. * // => objects for ['barney', 'fred']
  9410. *
  9411. * // The `_.property` iteratee shorthand.
  9412. * _.takeWhile(users, 'active');
  9413. * // => []
  9414. */
  9415. function takeWhile(array, predicate) {
  9416. return (array && array.length)
  9417. ? baseWhile(array, getIteratee(predicate, 3))
  9418. : [];
  9419. }
  9420. /**
  9421. * Creates an array of unique values, in order, from all given arrays using
  9422. * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
  9423. * for equality comparisons.
  9424. *
  9425. * @static
  9426. * @memberOf _
  9427. * @since 0.1.0
  9428. * @category Array
  9429. * @param {...Array} [arrays] The arrays to inspect.
  9430. * @returns {Array} Returns the new array of combined values.
  9431. * @example
  9432. *
  9433. * _.union([2], [1, 2]);
  9434. * // => [2, 1]
  9435. */
  9436. var union = baseRest(function(arrays) {
  9437. return baseUniq(baseFlatten(arrays, 1, isArrayLikeObject, true));
  9438. });
  9439. /**
  9440. * This method is like `_.union` except that it accepts `iteratee` which is
  9441. * invoked for each element of each `arrays` to generate the criterion by
  9442. * which uniqueness is computed. Result values are chosen from the first
  9443. * array in which the value occurs. The iteratee is invoked with one argument:
  9444. * (value).
  9445. *
  9446. * @static
  9447. * @memberOf _
  9448. * @since 4.0.0
  9449. * @category Array
  9450. * @param {...Array} [arrays] The arrays to inspect.
  9451. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  9452. * @returns {Array} Returns the new array of combined values.
  9453. * @example
  9454. *
  9455. * _.unionBy([2.1], [1.2, 2.3], Math.floor);
  9456. * // => [2.1, 1.2]
  9457. *
  9458. * // The `_.property` iteratee shorthand.
  9459. * _.unionBy([{ 'x': 1 }], [{ 'x': 2 }, { 'x': 1 }], 'x');
  9460. * // => [{ 'x': 1 }, { 'x': 2 }]
  9461. */
  9462. var unionBy = baseRest(function(arrays) {
  9463. var iteratee = last(arrays);
  9464. if (isArrayLikeObject(iteratee)) {
  9465. iteratee = undefined;
  9466. }
  9467. return baseUniq(baseFlatten(arrays, 1, isArrayLikeObject, true), getIteratee(iteratee, 2));
  9468. });
  9469. /**
  9470. * This method is like `_.union` except that it accepts `comparator` which
  9471. * is invoked to compare elements of `arrays`. Result values are chosen from
  9472. * the first array in which the value occurs. The comparator is invoked
  9473. * with two arguments: (arrVal, othVal).
  9474. *
  9475. * @static
  9476. * @memberOf _
  9477. * @since 4.0.0
  9478. * @category Array
  9479. * @param {...Array} [arrays] The arrays to inspect.
  9480. * @param {Function} [comparator] The comparator invoked per element.
  9481. * @returns {Array} Returns the new array of combined values.
  9482. * @example
  9483. *
  9484. * var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }];
  9485. * var others = [{ 'x': 1, 'y': 1 }, { 'x': 1, 'y': 2 }];
  9486. *
  9487. * _.unionWith(objects, others, _.isEqual);
  9488. * // => [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }, { 'x': 1, 'y': 1 }]
  9489. */
  9490. var unionWith = baseRest(function(arrays) {
  9491. var comparator = last(arrays);
  9492. comparator = typeof comparator == 'function' ? comparator : undefined;
  9493. return baseUniq(baseFlatten(arrays, 1, isArrayLikeObject, true), undefined, comparator);
  9494. });
  9495. /**
  9496. * Creates a duplicate-free version of an array, using
  9497. * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
  9498. * for equality comparisons, in which only the first occurrence of each element
  9499. * is kept. The order of result values is determined by the order they occur
  9500. * in the array.
  9501. *
  9502. * @static
  9503. * @memberOf _
  9504. * @since 0.1.0
  9505. * @category Array
  9506. * @param {Array} array The array to inspect.
  9507. * @returns {Array} Returns the new duplicate free array.
  9508. * @example
  9509. *
  9510. * _.uniq([2, 1, 2]);
  9511. * // => [2, 1]
  9512. */
  9513. function uniq(array) {
  9514. return (array && array.length) ? baseUniq(array) : [];
  9515. }
  9516. /**
  9517. * This method is like `_.uniq` except that it accepts `iteratee` which is
  9518. * invoked for each element in `array` to generate the criterion by which
  9519. * uniqueness is computed. The order of result values is determined by the
  9520. * order they occur in the array. The iteratee is invoked with one argument:
  9521. * (value).
  9522. *
  9523. * @static
  9524. * @memberOf _
  9525. * @since 4.0.0
  9526. * @category Array
  9527. * @param {Array} array The array to inspect.
  9528. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  9529. * @returns {Array} Returns the new duplicate free array.
  9530. * @example
  9531. *
  9532. * _.uniqBy([2.1, 1.2, 2.3], Math.floor);
  9533. * // => [2.1, 1.2]
  9534. *
  9535. * // The `_.property` iteratee shorthand.
  9536. * _.uniqBy([{ 'x': 1 }, { 'x': 2 }, { 'x': 1 }], 'x');
  9537. * // => [{ 'x': 1 }, { 'x': 2 }]
  9538. */
  9539. function uniqBy(array, iteratee) {
  9540. return (array && array.length) ? baseUniq(array, getIteratee(iteratee, 2)) : [];
  9541. }
  9542. /**
  9543. * This method is like `_.uniq` except that it accepts `comparator` which
  9544. * is invoked to compare elements of `array`. The order of result values is
  9545. * determined by the order they occur in the array.The comparator is invoked
  9546. * with two arguments: (arrVal, othVal).
  9547. *
  9548. * @static
  9549. * @memberOf _
  9550. * @since 4.0.0
  9551. * @category Array
  9552. * @param {Array} array The array to inspect.
  9553. * @param {Function} [comparator] The comparator invoked per element.
  9554. * @returns {Array} Returns the new duplicate free array.
  9555. * @example
  9556. *
  9557. * var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }, { 'x': 1, 'y': 2 }];
  9558. *
  9559. * _.uniqWith(objects, _.isEqual);
  9560. * // => [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }]
  9561. */
  9562. function uniqWith(array, comparator) {
  9563. comparator = typeof comparator == 'function' ? comparator : undefined;
  9564. return (array && array.length) ? baseUniq(array, undefined, comparator) : [];
  9565. }
  9566. /**
  9567. * This method is like `_.zip` except that it accepts an array of grouped
  9568. * elements and creates an array regrouping the elements to their pre-zip
  9569. * configuration.
  9570. *
  9571. * @static
  9572. * @memberOf _
  9573. * @since 1.2.0
  9574. * @category Array
  9575. * @param {Array} array The array of grouped elements to process.
  9576. * @returns {Array} Returns the new array of regrouped elements.
  9577. * @example
  9578. *
  9579. * var zipped = _.zip(['a', 'b'], [1, 2], [true, false]);
  9580. * // => [['a', 1, true], ['b', 2, false]]
  9581. *
  9582. * _.unzip(zipped);
  9583. * // => [['a', 'b'], [1, 2], [true, false]]
  9584. */
  9585. function unzip(array) {
  9586. if (!(array && array.length)) {
  9587. return [];
  9588. }
  9589. var length = 0;
  9590. array = arrayFilter(array, function(group) {
  9591. if (isArrayLikeObject(group)) {
  9592. length = nativeMax(group.length, length);
  9593. return true;
  9594. }
  9595. });
  9596. return baseTimes(length, function(index) {
  9597. return arrayMap(array, baseProperty(index));
  9598. });
  9599. }
  9600. /**
  9601. * This method is like `_.unzip` except that it accepts `iteratee` to specify
  9602. * how regrouped values should be combined. The iteratee is invoked with the
  9603. * elements of each group: (...group).
  9604. *
  9605. * @static
  9606. * @memberOf _
  9607. * @since 3.8.0
  9608. * @category Array
  9609. * @param {Array} array The array of grouped elements to process.
  9610. * @param {Function} [iteratee=_.identity] The function to combine
  9611. * regrouped values.
  9612. * @returns {Array} Returns the new array of regrouped elements.
  9613. * @example
  9614. *
  9615. * var zipped = _.zip([1, 2], [10, 20], [100, 200]);
  9616. * // => [[1, 10, 100], [2, 20, 200]]
  9617. *
  9618. * _.unzipWith(zipped, _.add);
  9619. * // => [3, 30, 300]
  9620. */
  9621. function unzipWith(array, iteratee) {
  9622. if (!(array && array.length)) {
  9623. return [];
  9624. }
  9625. var result = unzip(array);
  9626. if (iteratee == null) {
  9627. return result;
  9628. }
  9629. return arrayMap(result, function(group) {
  9630. return apply(iteratee, undefined, group);
  9631. });
  9632. }
  9633. /**
  9634. * Creates an array excluding all given values using
  9635. * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
  9636. * for equality comparisons.
  9637. *
  9638. * **Note:** Unlike `_.pull`, this method returns a new array.
  9639. *
  9640. * @static
  9641. * @memberOf _
  9642. * @since 0.1.0
  9643. * @category Array
  9644. * @param {Array} array The array to inspect.
  9645. * @param {...*} [values] The values to exclude.
  9646. * @returns {Array} Returns the new array of filtered values.
  9647. * @see _.difference, _.xor
  9648. * @example
  9649. *
  9650. * _.without([2, 1, 2, 3], 1, 2);
  9651. * // => [3]
  9652. */
  9653. var without = baseRest(function(array, values) {
  9654. return isArrayLikeObject(array)
  9655. ? baseDifference(array, values)
  9656. : [];
  9657. });
  9658. /**
  9659. * Creates an array of unique values that is the
  9660. * [symmetric difference](https://en.wikipedia.org/wiki/Symmetric_difference)
  9661. * of the given arrays. The order of result values is determined by the order
  9662. * they occur in the arrays.
  9663. *
  9664. * @static
  9665. * @memberOf _
  9666. * @since 2.4.0
  9667. * @category Array
  9668. * @param {...Array} [arrays] The arrays to inspect.
  9669. * @returns {Array} Returns the new array of filtered values.
  9670. * @see _.difference, _.without
  9671. * @example
  9672. *
  9673. * _.xor([2, 1], [2, 3]);
  9674. * // => [1, 3]
  9675. */
  9676. var xor = baseRest(function(arrays) {
  9677. return baseXor(arrayFilter(arrays, isArrayLikeObject));
  9678. });
  9679. /**
  9680. * This method is like `_.xor` except that it accepts `iteratee` which is
  9681. * invoked for each element of each `arrays` to generate the criterion by
  9682. * which by which they're compared. The order of result values is determined
  9683. * by the order they occur in the arrays. The iteratee is invoked with one
  9684. * argument: (value).
  9685. *
  9686. * @static
  9687. * @memberOf _
  9688. * @since 4.0.0
  9689. * @category Array
  9690. * @param {...Array} [arrays] The arrays to inspect.
  9691. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  9692. * @returns {Array} Returns the new array of filtered values.
  9693. * @example
  9694. *
  9695. * _.xorBy([2.1, 1.2], [2.3, 3.4], Math.floor);
  9696. * // => [1.2, 3.4]
  9697. *
  9698. * // The `_.property` iteratee shorthand.
  9699. * _.xorBy([{ 'x': 1 }], [{ 'x': 2 }, { 'x': 1 }], 'x');
  9700. * // => [{ 'x': 2 }]
  9701. */
  9702. var xorBy = baseRest(function(arrays) {
  9703. var iteratee = last(arrays);
  9704. if (isArrayLikeObject(iteratee)) {
  9705. iteratee = undefined;
  9706. }
  9707. return baseXor(arrayFilter(arrays, isArrayLikeObject), getIteratee(iteratee, 2));
  9708. });
  9709. /**
  9710. * This method is like `_.xor` except that it accepts `comparator` which is
  9711. * invoked to compare elements of `arrays`. The order of result values is
  9712. * determined by the order they occur in the arrays. The comparator is invoked
  9713. * with two arguments: (arrVal, othVal).
  9714. *
  9715. * @static
  9716. * @memberOf _
  9717. * @since 4.0.0
  9718. * @category Array
  9719. * @param {...Array} [arrays] The arrays to inspect.
  9720. * @param {Function} [comparator] The comparator invoked per element.
  9721. * @returns {Array} Returns the new array of filtered values.
  9722. * @example
  9723. *
  9724. * var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }];
  9725. * var others = [{ 'x': 1, 'y': 1 }, { 'x': 1, 'y': 2 }];
  9726. *
  9727. * _.xorWith(objects, others, _.isEqual);
  9728. * // => [{ 'x': 2, 'y': 1 }, { 'x': 1, 'y': 1 }]
  9729. */
  9730. var xorWith = baseRest(function(arrays) {
  9731. var comparator = last(arrays);
  9732. comparator = typeof comparator == 'function' ? comparator : undefined;
  9733. return baseXor(arrayFilter(arrays, isArrayLikeObject), undefined, comparator);
  9734. });
  9735. /**
  9736. * Creates an array of grouped elements, the first of which contains the
  9737. * first elements of the given arrays, the second of which contains the
  9738. * second elements of the given arrays, and so on.
  9739. *
  9740. * @static
  9741. * @memberOf _
  9742. * @since 0.1.0
  9743. * @category Array
  9744. * @param {...Array} [arrays] The arrays to process.
  9745. * @returns {Array} Returns the new array of grouped elements.
  9746. * @example
  9747. *
  9748. * _.zip(['a', 'b'], [1, 2], [true, false]);
  9749. * // => [['a', 1, true], ['b', 2, false]]
  9750. */
  9751. var zip = baseRest(unzip);
  9752. /**
  9753. * This method is like `_.fromPairs` except that it accepts two arrays,
  9754. * one of property identifiers and one of corresponding values.
  9755. *
  9756. * @static
  9757. * @memberOf _
  9758. * @since 0.4.0
  9759. * @category Array
  9760. * @param {Array} [props=[]] The property identifiers.
  9761. * @param {Array} [values=[]] The property values.
  9762. * @returns {Object} Returns the new object.
  9763. * @example
  9764. *
  9765. * _.zipObject(['a', 'b'], [1, 2]);
  9766. * // => { 'a': 1, 'b': 2 }
  9767. */
  9768. function zipObject(props, values) {
  9769. return baseZipObject(props || [], values || [], assignValue);
  9770. }
  9771. /**
  9772. * This method is like `_.zipObject` except that it supports property paths.
  9773. *
  9774. * @static
  9775. * @memberOf _
  9776. * @since 4.1.0
  9777. * @category Array
  9778. * @param {Array} [props=[]] The property identifiers.
  9779. * @param {Array} [values=[]] The property values.
  9780. * @returns {Object} Returns the new object.
  9781. * @example
  9782. *
  9783. * _.zipObjectDeep(['a.b[0].c', 'a.b[1].d'], [1, 2]);
  9784. * // => { 'a': { 'b': [{ 'c': 1 }, { 'd': 2 }] } }
  9785. */
  9786. function zipObjectDeep(props, values) {
  9787. return baseZipObject(props || [], values || [], baseSet);
  9788. }
  9789. /**
  9790. * This method is like `_.zip` except that it accepts `iteratee` to specify
  9791. * how grouped values should be combined. The iteratee is invoked with the
  9792. * elements of each group: (...group).
  9793. *
  9794. * @static
  9795. * @memberOf _
  9796. * @since 3.8.0
  9797. * @category Array
  9798. * @param {...Array} [arrays] The arrays to process.
  9799. * @param {Function} [iteratee=_.identity] The function to combine
  9800. * grouped values.
  9801. * @returns {Array} Returns the new array of grouped elements.
  9802. * @example
  9803. *
  9804. * _.zipWith([1, 2], [10, 20], [100, 200], function(a, b, c) {
  9805. * return a + b + c;
  9806. * });
  9807. * // => [111, 222]
  9808. */
  9809. var zipWith = baseRest(function(arrays) {
  9810. var length = arrays.length,
  9811. iteratee = length > 1 ? arrays[length - 1] : undefined;
  9812. iteratee = typeof iteratee == 'function' ? (arrays.pop(), iteratee) : undefined;
  9813. return unzipWith(arrays, iteratee);
  9814. });
  9815. /*------------------------------------------------------------------------*/
  9816. /**
  9817. * Creates a `lodash` wrapper instance that wraps `value` with explicit method
  9818. * chain sequences enabled. The result of such sequences must be unwrapped
  9819. * with `_#value`.
  9820. *
  9821. * @static
  9822. * @memberOf _
  9823. * @since 1.3.0
  9824. * @category Seq
  9825. * @param {*} value The value to wrap.
  9826. * @returns {Object} Returns the new `lodash` wrapper instance.
  9827. * @example
  9828. *
  9829. * var users = [
  9830. * { 'user': 'barney', 'age': 36 },
  9831. * { 'user': 'fred', 'age': 40 },
  9832. * { 'user': 'pebbles', 'age': 1 }
  9833. * ];
  9834. *
  9835. * var youngest = _
  9836. * .chain(users)
  9837. * .sortBy('age')
  9838. * .map(function(o) {
  9839. * return o.user + ' is ' + o.age;
  9840. * })
  9841. * .head()
  9842. * .value();
  9843. * // => 'pebbles is 1'
  9844. */
  9845. function chain(value) {
  9846. var result = lodash(value);
  9847. result.__chain__ = true;
  9848. return result;
  9849. }
  9850. /**
  9851. * This method invokes `interceptor` and returns `value`. The interceptor
  9852. * is invoked with one argument; (value). The purpose of this method is to
  9853. * "tap into" a method chain sequence in order to modify intermediate results.
  9854. *
  9855. * @static
  9856. * @memberOf _
  9857. * @since 0.1.0
  9858. * @category Seq
  9859. * @param {*} value The value to provide to `interceptor`.
  9860. * @param {Function} interceptor The function to invoke.
  9861. * @returns {*} Returns `value`.
  9862. * @example
  9863. *
  9864. * _([1, 2, 3])
  9865. * .tap(function(array) {
  9866. * // Mutate input array.
  9867. * array.pop();
  9868. * })
  9869. * .reverse()
  9870. * .value();
  9871. * // => [2, 1]
  9872. */
  9873. function tap(value, interceptor) {
  9874. interceptor(value);
  9875. return value;
  9876. }
  9877. /**
  9878. * This method is like `_.tap` except that it returns the result of `interceptor`.
  9879. * The purpose of this method is to "pass thru" values replacing intermediate
  9880. * results in a method chain sequence.
  9881. *
  9882. * @static
  9883. * @memberOf _
  9884. * @since 3.0.0
  9885. * @category Seq
  9886. * @param {*} value The value to provide to `interceptor`.
  9887. * @param {Function} interceptor The function to invoke.
  9888. * @returns {*} Returns the result of `interceptor`.
  9889. * @example
  9890. *
  9891. * _(' abc ')
  9892. * .chain()
  9893. * .trim()
  9894. * .thru(function(value) {
  9895. * return [value];
  9896. * })
  9897. * .value();
  9898. * // => ['abc']
  9899. */
  9900. function thru(value, interceptor) {
  9901. return interceptor(value);
  9902. }
  9903. /**
  9904. * This method is the wrapper version of `_.at`.
  9905. *
  9906. * @name at
  9907. * @memberOf _
  9908. * @since 1.0.0
  9909. * @category Seq
  9910. * @param {...(string|string[])} [paths] The property paths to pick.
  9911. * @returns {Object} Returns the new `lodash` wrapper instance.
  9912. * @example
  9913. *
  9914. * var object = { 'a': [{ 'b': { 'c': 3 } }, 4] };
  9915. *
  9916. * _(object).at(['a[0].b.c', 'a[1]']).value();
  9917. * // => [3, 4]
  9918. */
  9919. var wrapperAt = flatRest(function(paths) {
  9920. var length = paths.length,
  9921. start = length ? paths[0] : 0,
  9922. value = this.__wrapped__,
  9923. interceptor = function(object) { return baseAt(object, paths); };
  9924. if (length > 1 || this.__actions__.length ||
  9925. !(value instanceof LazyWrapper) || !isIndex(start)) {
  9926. return this.thru(interceptor);
  9927. }
  9928. value = value.slice(start, +start + (length ? 1 : 0));
  9929. value.__actions__.push({
  9930. 'func': thru,
  9931. 'args': [interceptor],
  9932. 'thisArg': undefined
  9933. });
  9934. return new LodashWrapper(value, this.__chain__).thru(function(array) {
  9935. if (length && !array.length) {
  9936. array.push(undefined);
  9937. }
  9938. return array;
  9939. });
  9940. });
  9941. /**
  9942. * Creates a `lodash` wrapper instance with explicit method chain sequences enabled.
  9943. *
  9944. * @name chain
  9945. * @memberOf _
  9946. * @since 0.1.0
  9947. * @category Seq
  9948. * @returns {Object} Returns the new `lodash` wrapper instance.
  9949. * @example
  9950. *
  9951. * var users = [
  9952. * { 'user': 'barney', 'age': 36 },
  9953. * { 'user': 'fred', 'age': 40 }
  9954. * ];
  9955. *
  9956. * // A sequence without explicit chaining.
  9957. * _(users).head();
  9958. * // => { 'user': 'barney', 'age': 36 }
  9959. *
  9960. * // A sequence with explicit chaining.
  9961. * _(users)
  9962. * .chain()
  9963. * .head()
  9964. * .pick('user')
  9965. * .value();
  9966. * // => { 'user': 'barney' }
  9967. */
  9968. function wrapperChain() {
  9969. return chain(this);
  9970. }
  9971. /**
  9972. * Executes the chain sequence and returns the wrapped result.
  9973. *
  9974. * @name commit
  9975. * @memberOf _
  9976. * @since 3.2.0
  9977. * @category Seq
  9978. * @returns {Object} Returns the new `lodash` wrapper instance.
  9979. * @example
  9980. *
  9981. * var array = [1, 2];
  9982. * var wrapped = _(array).push(3);
  9983. *
  9984. * console.log(array);
  9985. * // => [1, 2]
  9986. *
  9987. * wrapped = wrapped.commit();
  9988. * console.log(array);
  9989. * // => [1, 2, 3]
  9990. *
  9991. * wrapped.last();
  9992. * // => 3
  9993. *
  9994. * console.log(array);
  9995. * // => [1, 2, 3]
  9996. */
  9997. function wrapperCommit() {
  9998. return new LodashWrapper(this.value(), this.__chain__);
  9999. }
  10000. /**
  10001. * Gets the next value on a wrapped object following the
  10002. * [iterator protocol](https://mdn.io/iteration_protocols#iterator).
  10003. *
  10004. * @name next
  10005. * @memberOf _
  10006. * @since 4.0.0
  10007. * @category Seq
  10008. * @returns {Object} Returns the next iterator value.
  10009. * @example
  10010. *
  10011. * var wrapped = _([1, 2]);
  10012. *
  10013. * wrapped.next();
  10014. * // => { 'done': false, 'value': 1 }
  10015. *
  10016. * wrapped.next();
  10017. * // => { 'done': false, 'value': 2 }
  10018. *
  10019. * wrapped.next();
  10020. * // => { 'done': true, 'value': undefined }
  10021. */
  10022. function wrapperNext() {
  10023. if (this.__values__ === undefined) {
  10024. this.__values__ = toArray(this.value());
  10025. }
  10026. var done = this.__index__ >= this.__values__.length,
  10027. value = done ? undefined : this.__values__[this.__index__++];
  10028. return { 'done': done, 'value': value };
  10029. }
  10030. /**
  10031. * Enables the wrapper to be iterable.
  10032. *
  10033. * @name Symbol.iterator
  10034. * @memberOf _
  10035. * @since 4.0.0
  10036. * @category Seq
  10037. * @returns {Object} Returns the wrapper object.
  10038. * @example
  10039. *
  10040. * var wrapped = _([1, 2]);
  10041. *
  10042. * wrapped[Symbol.iterator]() === wrapped;
  10043. * // => true
  10044. *
  10045. * Array.from(wrapped);
  10046. * // => [1, 2]
  10047. */
  10048. function wrapperToIterator() {
  10049. return this;
  10050. }
  10051. /**
  10052. * Creates a clone of the chain sequence planting `value` as the wrapped value.
  10053. *
  10054. * @name plant
  10055. * @memberOf _
  10056. * @since 3.2.0
  10057. * @category Seq
  10058. * @param {*} value The value to plant.
  10059. * @returns {Object} Returns the new `lodash` wrapper instance.
  10060. * @example
  10061. *
  10062. * function square(n) {
  10063. * return n * n;
  10064. * }
  10065. *
  10066. * var wrapped = _([1, 2]).map(square);
  10067. * var other = wrapped.plant([3, 4]);
  10068. *
  10069. * other.value();
  10070. * // => [9, 16]
  10071. *
  10072. * wrapped.value();
  10073. * // => [1, 4]
  10074. */
  10075. function wrapperPlant(value) {
  10076. var result,
  10077. parent = this;
  10078. while (parent instanceof baseLodash) {
  10079. var clone = wrapperClone(parent);
  10080. clone.__index__ = 0;
  10081. clone.__values__ = undefined;
  10082. if (result) {
  10083. previous.__wrapped__ = clone;
  10084. } else {
  10085. result = clone;
  10086. }
  10087. var previous = clone;
  10088. parent = parent.__wrapped__;
  10089. }
  10090. previous.__wrapped__ = value;
  10091. return result;
  10092. }
  10093. /**
  10094. * This method is the wrapper version of `_.reverse`.
  10095. *
  10096. * **Note:** This method mutates the wrapped array.
  10097. *
  10098. * @name reverse
  10099. * @memberOf _
  10100. * @since 0.1.0
  10101. * @category Seq
  10102. * @returns {Object} Returns the new `lodash` wrapper instance.
  10103. * @example
  10104. *
  10105. * var array = [1, 2, 3];
  10106. *
  10107. * _(array).reverse().value()
  10108. * // => [3, 2, 1]
  10109. *
  10110. * console.log(array);
  10111. * // => [3, 2, 1]
  10112. */
  10113. function wrapperReverse() {
  10114. var value = this.__wrapped__;
  10115. if (value instanceof LazyWrapper) {
  10116. var wrapped = value;
  10117. if (this.__actions__.length) {
  10118. wrapped = new LazyWrapper(this);
  10119. }
  10120. wrapped = wrapped.reverse();
  10121. wrapped.__actions__.push({
  10122. 'func': thru,
  10123. 'args': [reverse],
  10124. 'thisArg': undefined
  10125. });
  10126. return new LodashWrapper(wrapped, this.__chain__);
  10127. }
  10128. return this.thru(reverse);
  10129. }
  10130. /**
  10131. * Executes the chain sequence to resolve the unwrapped value.
  10132. *
  10133. * @name value
  10134. * @memberOf _
  10135. * @since 0.1.0
  10136. * @alias toJSON, valueOf
  10137. * @category Seq
  10138. * @returns {*} Returns the resolved unwrapped value.
  10139. * @example
  10140. *
  10141. * _([1, 2, 3]).value();
  10142. * // => [1, 2, 3]
  10143. */
  10144. function wrapperValue() {
  10145. return baseWrapperValue(this.__wrapped__, this.__actions__);
  10146. }
  10147. /*------------------------------------------------------------------------*/
  10148. /**
  10149. * Creates an object composed of keys generated from the results of running
  10150. * each element of `collection` thru `iteratee`. The corresponding value of
  10151. * each key is the number of times the key was returned by `iteratee`. The
  10152. * iteratee is invoked with one argument: (value).
  10153. *
  10154. * @static
  10155. * @memberOf _
  10156. * @since 0.5.0
  10157. * @category Collection
  10158. * @param {Array|Object} collection The collection to iterate over.
  10159. * @param {Function} [iteratee=_.identity] The iteratee to transform keys.
  10160. * @returns {Object} Returns the composed aggregate object.
  10161. * @example
  10162. *
  10163. * _.countBy([6.1, 4.2, 6.3], Math.floor);
  10164. * // => { '4': 1, '6': 2 }
  10165. *
  10166. * // The `_.property` iteratee shorthand.
  10167. * _.countBy(['one', 'two', 'three'], 'length');
  10168. * // => { '3': 2, '5': 1 }
  10169. */
  10170. var countBy = createAggregator(function(result, value, key) {
  10171. if (hasOwnProperty.call(result, key)) {
  10172. ++result[key];
  10173. } else {
  10174. baseAssignValue(result, key, 1);
  10175. }
  10176. });
  10177. /**
  10178. * Checks if `predicate` returns truthy for **all** elements of `collection`.
  10179. * Iteration is stopped once `predicate` returns falsey. The predicate is
  10180. * invoked with three arguments: (value, index|key, collection).
  10181. *
  10182. * **Note:** This method returns `true` for
  10183. * [empty collections](https://en.wikipedia.org/wiki/Empty_set) because
  10184. * [everything is true](https://en.wikipedia.org/wiki/Vacuous_truth) of
  10185. * elements of empty collections.
  10186. *
  10187. * @static
  10188. * @memberOf _
  10189. * @since 0.1.0
  10190. * @category Collection
  10191. * @param {Array|Object} collection The collection to iterate over.
  10192. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  10193. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  10194. * @returns {boolean} Returns `true` if all elements pass the predicate check,
  10195. * else `false`.
  10196. * @example
  10197. *
  10198. * _.every([true, 1, null, 'yes'], Boolean);
  10199. * // => false
  10200. *
  10201. * var users = [
  10202. * { 'user': 'barney', 'age': 36, 'active': false },
  10203. * { 'user': 'fred', 'age': 40, 'active': false }
  10204. * ];
  10205. *
  10206. * // The `_.matches` iteratee shorthand.
  10207. * _.every(users, { 'user': 'barney', 'active': false });
  10208. * // => false
  10209. *
  10210. * // The `_.matchesProperty` iteratee shorthand.
  10211. * _.every(users, ['active', false]);
  10212. * // => true
  10213. *
  10214. * // The `_.property` iteratee shorthand.
  10215. * _.every(users, 'active');
  10216. * // => false
  10217. */
  10218. function every(collection, predicate, guard) {
  10219. var func = isArray(collection) ? arrayEvery : baseEvery;
  10220. if (guard && isIterateeCall(collection, predicate, guard)) {
  10221. predicate = undefined;
  10222. }
  10223. return func(collection, getIteratee(predicate, 3));
  10224. }
  10225. /**
  10226. * Iterates over elements of `collection`, returning an array of all elements
  10227. * `predicate` returns truthy for. The predicate is invoked with three
  10228. * arguments: (value, index|key, collection).
  10229. *
  10230. * **Note:** Unlike `_.remove`, this method returns a new array.
  10231. *
  10232. * @static
  10233. * @memberOf _
  10234. * @since 0.1.0
  10235. * @category Collection
  10236. * @param {Array|Object} collection The collection to iterate over.
  10237. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  10238. * @returns {Array} Returns the new filtered array.
  10239. * @see _.reject
  10240. * @example
  10241. *
  10242. * var users = [
  10243. * { 'user': 'barney', 'age': 36, 'active': true },
  10244. * { 'user': 'fred', 'age': 40, 'active': false }
  10245. * ];
  10246. *
  10247. * _.filter(users, function(o) { return !o.active; });
  10248. * // => objects for ['fred']
  10249. *
  10250. * // The `_.matches` iteratee shorthand.
  10251. * _.filter(users, { 'age': 36, 'active': true });
  10252. * // => objects for ['barney']
  10253. *
  10254. * // The `_.matchesProperty` iteratee shorthand.
  10255. * _.filter(users, ['active', false]);
  10256. * // => objects for ['fred']
  10257. *
  10258. * // The `_.property` iteratee shorthand.
  10259. * _.filter(users, 'active');
  10260. * // => objects for ['barney']
  10261. *
  10262. * // Combining several predicates using `_.overEvery` or `_.overSome`.
  10263. * _.filter(users, _.overSome([{ 'age': 36 }, ['age', 40]]));
  10264. * // => objects for ['fred', 'barney']
  10265. */
  10266. function filter(collection, predicate) {
  10267. var func = isArray(collection) ? arrayFilter : baseFilter;
  10268. return func(collection, getIteratee(predicate, 3));
  10269. }
  10270. /**
  10271. * Iterates over elements of `collection`, returning the first element
  10272. * `predicate` returns truthy for. The predicate is invoked with three
  10273. * arguments: (value, index|key, collection).
  10274. *
  10275. * @static
  10276. * @memberOf _
  10277. * @since 0.1.0
  10278. * @category Collection
  10279. * @param {Array|Object} collection The collection to inspect.
  10280. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  10281. * @param {number} [fromIndex=0] The index to search from.
  10282. * @returns {*} Returns the matched element, else `undefined`.
  10283. * @example
  10284. *
  10285. * var users = [
  10286. * { 'user': 'barney', 'age': 36, 'active': true },
  10287. * { 'user': 'fred', 'age': 40, 'active': false },
  10288. * { 'user': 'pebbles', 'age': 1, 'active': true }
  10289. * ];
  10290. *
  10291. * _.find(users, function(o) { return o.age < 40; });
  10292. * // => object for 'barney'
  10293. *
  10294. * // The `_.matches` iteratee shorthand.
  10295. * _.find(users, { 'age': 1, 'active': true });
  10296. * // => object for 'pebbles'
  10297. *
  10298. * // The `_.matchesProperty` iteratee shorthand.
  10299. * _.find(users, ['active', false]);
  10300. * // => object for 'fred'
  10301. *
  10302. * // The `_.property` iteratee shorthand.
  10303. * _.find(users, 'active');
  10304. * // => object for 'barney'
  10305. */
  10306. var find = createFind(findIndex);
  10307. /**
  10308. * This method is like `_.find` except that it iterates over elements of
  10309. * `collection` from right to left.
  10310. *
  10311. * @static
  10312. * @memberOf _
  10313. * @since 2.0.0
  10314. * @category Collection
  10315. * @param {Array|Object} collection The collection to inspect.
  10316. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  10317. * @param {number} [fromIndex=collection.length-1] The index to search from.
  10318. * @returns {*} Returns the matched element, else `undefined`.
  10319. * @example
  10320. *
  10321. * _.findLast([1, 2, 3, 4], function(n) {
  10322. * return n % 2 == 1;
  10323. * });
  10324. * // => 3
  10325. */
  10326. var findLast = createFind(findLastIndex);
  10327. /**
  10328. * Creates a flattened array of values by running each element in `collection`
  10329. * thru `iteratee` and flattening the mapped results. The iteratee is invoked
  10330. * with three arguments: (value, index|key, collection).
  10331. *
  10332. * @static
  10333. * @memberOf _
  10334. * @since 4.0.0
  10335. * @category Collection
  10336. * @param {Array|Object} collection The collection to iterate over.
  10337. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  10338. * @returns {Array} Returns the new flattened array.
  10339. * @example
  10340. *
  10341. * function duplicate(n) {
  10342. * return [n, n];
  10343. * }
  10344. *
  10345. * _.flatMap([1, 2], duplicate);
  10346. * // => [1, 1, 2, 2]
  10347. */
  10348. function flatMap(collection, iteratee) {
  10349. return baseFlatten(map(collection, iteratee), 1);
  10350. }
  10351. /**
  10352. * This method is like `_.flatMap` except that it recursively flattens the
  10353. * mapped results.
  10354. *
  10355. * @static
  10356. * @memberOf _
  10357. * @since 4.7.0
  10358. * @category Collection
  10359. * @param {Array|Object} collection The collection to iterate over.
  10360. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  10361. * @returns {Array} Returns the new flattened array.
  10362. * @example
  10363. *
  10364. * function duplicate(n) {
  10365. * return [[[n, n]]];
  10366. * }
  10367. *
  10368. * _.flatMapDeep([1, 2], duplicate);
  10369. * // => [1, 1, 2, 2]
  10370. */
  10371. function flatMapDeep(collection, iteratee) {
  10372. return baseFlatten(map(collection, iteratee), INFINITY);
  10373. }
  10374. /**
  10375. * This method is like `_.flatMap` except that it recursively flattens the
  10376. * mapped results up to `depth` times.
  10377. *
  10378. * @static
  10379. * @memberOf _
  10380. * @since 4.7.0
  10381. * @category Collection
  10382. * @param {Array|Object} collection The collection to iterate over.
  10383. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  10384. * @param {number} [depth=1] The maximum recursion depth.
  10385. * @returns {Array} Returns the new flattened array.
  10386. * @example
  10387. *
  10388. * function duplicate(n) {
  10389. * return [[[n, n]]];
  10390. * }
  10391. *
  10392. * _.flatMapDepth([1, 2], duplicate, 2);
  10393. * // => [[1, 1], [2, 2]]
  10394. */
  10395. function flatMapDepth(collection, iteratee, depth) {
  10396. depth = depth === undefined ? 1 : toInteger(depth);
  10397. return baseFlatten(map(collection, iteratee), depth);
  10398. }
  10399. /**
  10400. * Iterates over elements of `collection` and invokes `iteratee` for each element.
  10401. * The iteratee is invoked with three arguments: (value, index|key, collection).
  10402. * Iteratee functions may exit iteration early by explicitly returning `false`.
  10403. *
  10404. * **Note:** As with other "Collections" methods, objects with a "length"
  10405. * property are iterated like arrays. To avoid this behavior use `_.forIn`
  10406. * or `_.forOwn` for object iteration.
  10407. *
  10408. * @static
  10409. * @memberOf _
  10410. * @since 0.1.0
  10411. * @alias each
  10412. * @category Collection
  10413. * @param {Array|Object} collection The collection to iterate over.
  10414. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  10415. * @returns {Array|Object} Returns `collection`.
  10416. * @see _.forEachRight
  10417. * @example
  10418. *
  10419. * _.forEach([1, 2], function(value) {
  10420. * console.log(value);
  10421. * });
  10422. * // => Logs `1` then `2`.
  10423. *
  10424. * _.forEach({ 'a': 1, 'b': 2 }, function(value, key) {
  10425. * console.log(key);
  10426. * });
  10427. * // => Logs 'a' then 'b' (iteration order is not guaranteed).
  10428. */
  10429. function forEach(collection, iteratee) {
  10430. var func = isArray(collection) ? arrayEach : baseEach;
  10431. return func(collection, getIteratee(iteratee, 3));
  10432. }
  10433. /**
  10434. * This method is like `_.forEach` except that it iterates over elements of
  10435. * `collection` from right to left.
  10436. *
  10437. * @static
  10438. * @memberOf _
  10439. * @since 2.0.0
  10440. * @alias eachRight
  10441. * @category Collection
  10442. * @param {Array|Object} collection The collection to iterate over.
  10443. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  10444. * @returns {Array|Object} Returns `collection`.
  10445. * @see _.forEach
  10446. * @example
  10447. *
  10448. * _.forEachRight([1, 2], function(value) {
  10449. * console.log(value);
  10450. * });
  10451. * // => Logs `2` then `1`.
  10452. */
  10453. function forEachRight(collection, iteratee) {
  10454. var func = isArray(collection) ? arrayEachRight : baseEachRight;
  10455. return func(collection, getIteratee(iteratee, 3));
  10456. }
  10457. /**
  10458. * Creates an object composed of keys generated from the results of running
  10459. * each element of `collection` thru `iteratee`. The order of grouped values
  10460. * is determined by the order they occur in `collection`. The corresponding
  10461. * value of each key is an array of elements responsible for generating the
  10462. * key. The iteratee is invoked with one argument: (value).
  10463. *
  10464. * @static
  10465. * @memberOf _
  10466. * @since 0.1.0
  10467. * @category Collection
  10468. * @param {Array|Object} collection The collection to iterate over.
  10469. * @param {Function} [iteratee=_.identity] The iteratee to transform keys.
  10470. * @returns {Object} Returns the composed aggregate object.
  10471. * @example
  10472. *
  10473. * _.groupBy([6.1, 4.2, 6.3], Math.floor);
  10474. * // => { '4': [4.2], '6': [6.1, 6.3] }
  10475. *
  10476. * // The `_.property` iteratee shorthand.
  10477. * _.groupBy(['one', 'two', 'three'], 'length');
  10478. * // => { '3': ['one', 'two'], '5': ['three'] }
  10479. */
  10480. var groupBy = createAggregator(function(result, value, key) {
  10481. if (hasOwnProperty.call(result, key)) {
  10482. result[key].push(value);
  10483. } else {
  10484. baseAssignValue(result, key, [value]);
  10485. }
  10486. });
  10487. /**
  10488. * Checks if `value` is in `collection`. If `collection` is a string, it's
  10489. * checked for a substring of `value`, otherwise
  10490. * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
  10491. * is used for equality comparisons. If `fromIndex` is negative, it's used as
  10492. * the offset from the end of `collection`.
  10493. *
  10494. * @static
  10495. * @memberOf _
  10496. * @since 0.1.0
  10497. * @category Collection
  10498. * @param {Array|Object|string} collection The collection to inspect.
  10499. * @param {*} value The value to search for.
  10500. * @param {number} [fromIndex=0] The index to search from.
  10501. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.reduce`.
  10502. * @returns {boolean} Returns `true` if `value` is found, else `false`.
  10503. * @example
  10504. *
  10505. * _.includes([1, 2, 3], 1);
  10506. * // => true
  10507. *
  10508. * _.includes([1, 2, 3], 1, 2);
  10509. * // => false
  10510. *
  10511. * _.includes({ 'a': 1, 'b': 2 }, 1);
  10512. * // => true
  10513. *
  10514. * _.includes('abcd', 'bc');
  10515. * // => true
  10516. */
  10517. function includes(collection, value, fromIndex, guard) {
  10518. collection = isArrayLike(collection) ? collection : values(collection);
  10519. fromIndex = (fromIndex && !guard) ? toInteger(fromIndex) : 0;
  10520. var length = collection.length;
  10521. if (fromIndex < 0) {
  10522. fromIndex = nativeMax(length + fromIndex, 0);
  10523. }
  10524. return isString(collection)
  10525. ? (fromIndex <= length && collection.indexOf(value, fromIndex) > -1)
  10526. : (!!length && baseIndexOf(collection, value, fromIndex) > -1);
  10527. }
  10528. /**
  10529. * Invokes the method at `path` of each element in `collection`, returning
  10530. * an array of the results of each invoked method. Any additional arguments
  10531. * are provided to each invoked method. If `path` is a function, it's invoked
  10532. * for, and `this` bound to, each element in `collection`.
  10533. *
  10534. * @static
  10535. * @memberOf _
  10536. * @since 4.0.0
  10537. * @category Collection
  10538. * @param {Array|Object} collection The collection to iterate over.
  10539. * @param {Array|Function|string} path The path of the method to invoke or
  10540. * the function invoked per iteration.
  10541. * @param {...*} [args] The arguments to invoke each method with.
  10542. * @returns {Array} Returns the array of results.
  10543. * @example
  10544. *
  10545. * _.invokeMap([[5, 1, 7], [3, 2, 1]], 'sort');
  10546. * // => [[1, 5, 7], [1, 2, 3]]
  10547. *
  10548. * _.invokeMap([123, 456], String.prototype.split, '');
  10549. * // => [['1', '2', '3'], ['4', '5', '6']]
  10550. */
  10551. var invokeMap = baseRest(function(collection, path, args) {
  10552. var index = -1,
  10553. isFunc = typeof path == 'function',
  10554. result = isArrayLike(collection) ? Array(collection.length) : [];
  10555. baseEach(collection, function(value) {
  10556. result[++index] = isFunc ? apply(path, value, args) : baseInvoke(value, path, args);
  10557. });
  10558. return result;
  10559. });
  10560. /**
  10561. * Creates an object composed of keys generated from the results of running
  10562. * each element of `collection` thru `iteratee`. The corresponding value of
  10563. * each key is the last element responsible for generating the key. The
  10564. * iteratee is invoked with one argument: (value).
  10565. *
  10566. * @static
  10567. * @memberOf _
  10568. * @since 4.0.0
  10569. * @category Collection
  10570. * @param {Array|Object} collection The collection to iterate over.
  10571. * @param {Function} [iteratee=_.identity] The iteratee to transform keys.
  10572. * @returns {Object} Returns the composed aggregate object.
  10573. * @example
  10574. *
  10575. * var array = [
  10576. * { 'dir': 'left', 'code': 97 },
  10577. * { 'dir': 'right', 'code': 100 }
  10578. * ];
  10579. *
  10580. * _.keyBy(array, function(o) {
  10581. * return String.fromCharCode(o.code);
  10582. * });
  10583. * // => { 'a': { 'dir': 'left', 'code': 97 }, 'd': { 'dir': 'right', 'code': 100 } }
  10584. *
  10585. * _.keyBy(array, 'dir');
  10586. * // => { 'left': { 'dir': 'left', 'code': 97 }, 'right': { 'dir': 'right', 'code': 100 } }
  10587. */
  10588. var keyBy = createAggregator(function(result, value, key) {
  10589. baseAssignValue(result, key, value);
  10590. });
  10591. /**
  10592. * Creates an array of values by running each element in `collection` thru
  10593. * `iteratee`. The iteratee is invoked with three arguments:
  10594. * (value, index|key, collection).
  10595. *
  10596. * Many lodash methods are guarded to work as iteratees for methods like
  10597. * `_.every`, `_.filter`, `_.map`, `_.mapValues`, `_.reject`, and `_.some`.
  10598. *
  10599. * The guarded methods are:
  10600. * `ary`, `chunk`, `curry`, `curryRight`, `drop`, `dropRight`, `every`,
  10601. * `fill`, `invert`, `parseInt`, `random`, `range`, `rangeRight`, `repeat`,
  10602. * `sampleSize`, `slice`, `some`, `sortBy`, `split`, `take`, `takeRight`,
  10603. * `template`, `trim`, `trimEnd`, `trimStart`, and `words`
  10604. *
  10605. * @static
  10606. * @memberOf _
  10607. * @since 0.1.0
  10608. * @category Collection
  10609. * @param {Array|Object} collection The collection to iterate over.
  10610. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  10611. * @returns {Array} Returns the new mapped array.
  10612. * @example
  10613. *
  10614. * function square(n) {
  10615. * return n * n;
  10616. * }
  10617. *
  10618. * _.map([4, 8], square);
  10619. * // => [16, 64]
  10620. *
  10621. * _.map({ 'a': 4, 'b': 8 }, square);
  10622. * // => [16, 64] (iteration order is not guaranteed)
  10623. *
  10624. * var users = [
  10625. * { 'user': 'barney' },
  10626. * { 'user': 'fred' }
  10627. * ];
  10628. *
  10629. * // The `_.property` iteratee shorthand.
  10630. * _.map(users, 'user');
  10631. * // => ['barney', 'fred']
  10632. */
  10633. function map(collection, iteratee) {
  10634. var func = isArray(collection) ? arrayMap : baseMap;
  10635. return func(collection, getIteratee(iteratee, 3));
  10636. }
  10637. /**
  10638. * This method is like `_.sortBy` except that it allows specifying the sort
  10639. * orders of the iteratees to sort by. If `orders` is unspecified, all values
  10640. * are sorted in ascending order. Otherwise, specify an order of "desc" for
  10641. * descending or "asc" for ascending sort order of corresponding values.
  10642. *
  10643. * @static
  10644. * @memberOf _
  10645. * @since 4.0.0
  10646. * @category Collection
  10647. * @param {Array|Object} collection The collection to iterate over.
  10648. * @param {Array[]|Function[]|Object[]|string[]} [iteratees=[_.identity]]
  10649. * The iteratees to sort by.
  10650. * @param {string[]} [orders] The sort orders of `iteratees`.
  10651. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.reduce`.
  10652. * @returns {Array} Returns the new sorted array.
  10653. * @example
  10654. *
  10655. * var users = [
  10656. * { 'user': 'fred', 'age': 48 },
  10657. * { 'user': 'barney', 'age': 34 },
  10658. * { 'user': 'fred', 'age': 40 },
  10659. * { 'user': 'barney', 'age': 36 }
  10660. * ];
  10661. *
  10662. * // Sort by `user` in ascending order and by `age` in descending order.
  10663. * _.orderBy(users, ['user', 'age'], ['asc', 'desc']);
  10664. * // => objects for [['barney', 36], ['barney', 34], ['fred', 48], ['fred', 40]]
  10665. */
  10666. function orderBy(collection, iteratees, orders, guard) {
  10667. if (collection == null) {
  10668. return [];
  10669. }
  10670. if (!isArray(iteratees)) {
  10671. iteratees = iteratees == null ? [] : [iteratees];
  10672. }
  10673. orders = guard ? undefined : orders;
  10674. if (!isArray(orders)) {
  10675. orders = orders == null ? [] : [orders];
  10676. }
  10677. return baseOrderBy(collection, iteratees, orders);
  10678. }
  10679. /**
  10680. * Creates an array of elements split into two groups, the first of which
  10681. * contains elements `predicate` returns truthy for, the second of which
  10682. * contains elements `predicate` returns falsey for. The predicate is
  10683. * invoked with one argument: (value).
  10684. *
  10685. * @static
  10686. * @memberOf _
  10687. * @since 3.0.0
  10688. * @category Collection
  10689. * @param {Array|Object} collection The collection to iterate over.
  10690. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  10691. * @returns {Array} Returns the array of grouped elements.
  10692. * @example
  10693. *
  10694. * var users = [
  10695. * { 'user': 'barney', 'age': 36, 'active': false },
  10696. * { 'user': 'fred', 'age': 40, 'active': true },
  10697. * { 'user': 'pebbles', 'age': 1, 'active': false }
  10698. * ];
  10699. *
  10700. * _.partition(users, function(o) { return o.active; });
  10701. * // => objects for [['fred'], ['barney', 'pebbles']]
  10702. *
  10703. * // The `_.matches` iteratee shorthand.
  10704. * _.partition(users, { 'age': 1, 'active': false });
  10705. * // => objects for [['pebbles'], ['barney', 'fred']]
  10706. *
  10707. * // The `_.matchesProperty` iteratee shorthand.
  10708. * _.partition(users, ['active', false]);
  10709. * // => objects for [['barney', 'pebbles'], ['fred']]
  10710. *
  10711. * // The `_.property` iteratee shorthand.
  10712. * _.partition(users, 'active');
  10713. * // => objects for [['fred'], ['barney', 'pebbles']]
  10714. */
  10715. var partition = createAggregator(function(result, value, key) {
  10716. result[key ? 0 : 1].push(value);
  10717. }, function() { return [[], []]; });
  10718. /**
  10719. * Reduces `collection` to a value which is the accumulated result of running
  10720. * each element in `collection` thru `iteratee`, where each successive
  10721. * invocation is supplied the return value of the previous. If `accumulator`
  10722. * is not given, the first element of `collection` is used as the initial
  10723. * value. The iteratee is invoked with four arguments:
  10724. * (accumulator, value, index|key, collection).
  10725. *
  10726. * Many lodash methods are guarded to work as iteratees for methods like
  10727. * `_.reduce`, `_.reduceRight`, and `_.transform`.
  10728. *
  10729. * The guarded methods are:
  10730. * `assign`, `defaults`, `defaultsDeep`, `includes`, `merge`, `orderBy`,
  10731. * and `sortBy`
  10732. *
  10733. * @static
  10734. * @memberOf _
  10735. * @since 0.1.0
  10736. * @category Collection
  10737. * @param {Array|Object} collection The collection to iterate over.
  10738. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  10739. * @param {*} [accumulator] The initial value.
  10740. * @returns {*} Returns the accumulated value.
  10741. * @see _.reduceRight
  10742. * @example
  10743. *
  10744. * _.reduce([1, 2], function(sum, n) {
  10745. * return sum + n;
  10746. * }, 0);
  10747. * // => 3
  10748. *
  10749. * _.reduce({ 'a': 1, 'b': 2, 'c': 1 }, function(result, value, key) {
  10750. * (result[value] || (result[value] = [])).push(key);
  10751. * return result;
  10752. * }, {});
  10753. * // => { '1': ['a', 'c'], '2': ['b'] } (iteration order is not guaranteed)
  10754. */
  10755. function reduce(collection, iteratee, accumulator) {
  10756. var func = isArray(collection) ? arrayReduce : baseReduce,
  10757. initAccum = arguments.length < 3;
  10758. return func(collection, getIteratee(iteratee, 4), accumulator, initAccum, baseEach);
  10759. }
  10760. /**
  10761. * This method is like `_.reduce` except that it iterates over elements of
  10762. * `collection` from right to left.
  10763. *
  10764. * @static
  10765. * @memberOf _
  10766. * @since 0.1.0
  10767. * @category Collection
  10768. * @param {Array|Object} collection The collection to iterate over.
  10769. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  10770. * @param {*} [accumulator] The initial value.
  10771. * @returns {*} Returns the accumulated value.
  10772. * @see _.reduce
  10773. * @example
  10774. *
  10775. * var array = [[0, 1], [2, 3], [4, 5]];
  10776. *
  10777. * _.reduceRight(array, function(flattened, other) {
  10778. * return flattened.concat(other);
  10779. * }, []);
  10780. * // => [4, 5, 2, 3, 0, 1]
  10781. */
  10782. function reduceRight(collection, iteratee, accumulator) {
  10783. var func = isArray(collection) ? arrayReduceRight : baseReduce,
  10784. initAccum = arguments.length < 3;
  10785. return func(collection, getIteratee(iteratee, 4), accumulator, initAccum, baseEachRight);
  10786. }
  10787. /**
  10788. * The opposite of `_.filter`; this method returns the elements of `collection`
  10789. * that `predicate` does **not** return truthy for.
  10790. *
  10791. * @static
  10792. * @memberOf _
  10793. * @since 0.1.0
  10794. * @category Collection
  10795. * @param {Array|Object} collection The collection to iterate over.
  10796. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  10797. * @returns {Array} Returns the new filtered array.
  10798. * @see _.filter
  10799. * @example
  10800. *
  10801. * var users = [
  10802. * { 'user': 'barney', 'age': 36, 'active': false },
  10803. * { 'user': 'fred', 'age': 40, 'active': true }
  10804. * ];
  10805. *
  10806. * _.reject(users, function(o) { return !o.active; });
  10807. * // => objects for ['fred']
  10808. *
  10809. * // The `_.matches` iteratee shorthand.
  10810. * _.reject(users, { 'age': 40, 'active': true });
  10811. * // => objects for ['barney']
  10812. *
  10813. * // The `_.matchesProperty` iteratee shorthand.
  10814. * _.reject(users, ['active', false]);
  10815. * // => objects for ['fred']
  10816. *
  10817. * // The `_.property` iteratee shorthand.
  10818. * _.reject(users, 'active');
  10819. * // => objects for ['barney']
  10820. */
  10821. function reject(collection, predicate) {
  10822. var func = isArray(collection) ? arrayFilter : baseFilter;
  10823. return func(collection, negate(getIteratee(predicate, 3)));
  10824. }
  10825. /**
  10826. * Gets a random element from `collection`.
  10827. *
  10828. * @static
  10829. * @memberOf _
  10830. * @since 2.0.0
  10831. * @category Collection
  10832. * @param {Array|Object} collection The collection to sample.
  10833. * @returns {*} Returns the random element.
  10834. * @example
  10835. *
  10836. * _.sample([1, 2, 3, 4]);
  10837. * // => 2
  10838. */
  10839. function sample(collection) {
  10840. var func = isArray(collection) ? arraySample : baseSample;
  10841. return func(collection);
  10842. }
  10843. /**
  10844. * Gets `n` random elements at unique keys from `collection` up to the
  10845. * size of `collection`.
  10846. *
  10847. * @static
  10848. * @memberOf _
  10849. * @since 4.0.0
  10850. * @category Collection
  10851. * @param {Array|Object} collection The collection to sample.
  10852. * @param {number} [n=1] The number of elements to sample.
  10853. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  10854. * @returns {Array} Returns the random elements.
  10855. * @example
  10856. *
  10857. * _.sampleSize([1, 2, 3], 2);
  10858. * // => [3, 1]
  10859. *
  10860. * _.sampleSize([1, 2, 3], 4);
  10861. * // => [2, 3, 1]
  10862. */
  10863. function sampleSize(collection, n, guard) {
  10864. if ((guard ? isIterateeCall(collection, n, guard) : n === undefined)) {
  10865. n = 1;
  10866. } else {
  10867. n = toInteger(n);
  10868. }
  10869. var func = isArray(collection) ? arraySampleSize : baseSampleSize;
  10870. return func(collection, n);
  10871. }
  10872. /**
  10873. * Creates an array of shuffled values, using a version of the
  10874. * [Fisher-Yates shuffle](https://en.wikipedia.org/wiki/Fisher-Yates_shuffle).
  10875. *
  10876. * @static
  10877. * @memberOf _
  10878. * @since 0.1.0
  10879. * @category Collection
  10880. * @param {Array|Object} collection The collection to shuffle.
  10881. * @returns {Array} Returns the new shuffled array.
  10882. * @example
  10883. *
  10884. * _.shuffle([1, 2, 3, 4]);
  10885. * // => [4, 1, 3, 2]
  10886. */
  10887. function shuffle(collection) {
  10888. var func = isArray(collection) ? arrayShuffle : baseShuffle;
  10889. return func(collection);
  10890. }
  10891. /**
  10892. * Gets the size of `collection` by returning its length for array-like
  10893. * values or the number of own enumerable string keyed properties for objects.
  10894. *
  10895. * @static
  10896. * @memberOf _
  10897. * @since 0.1.0
  10898. * @category Collection
  10899. * @param {Array|Object|string} collection The collection to inspect.
  10900. * @returns {number} Returns the collection size.
  10901. * @example
  10902. *
  10903. * _.size([1, 2, 3]);
  10904. * // => 3
  10905. *
  10906. * _.size({ 'a': 1, 'b': 2 });
  10907. * // => 2
  10908. *
  10909. * _.size('pebbles');
  10910. * // => 7
  10911. */
  10912. function size(collection) {
  10913. if (collection == null) {
  10914. return 0;
  10915. }
  10916. if (isArrayLike(collection)) {
  10917. return isString(collection) ? stringSize(collection) : collection.length;
  10918. }
  10919. var tag = getTag(collection);
  10920. if (tag == mapTag || tag == setTag) {
  10921. return collection.size;
  10922. }
  10923. return baseKeys(collection).length;
  10924. }
  10925. /**
  10926. * Checks if `predicate` returns truthy for **any** element of `collection`.
  10927. * Iteration is stopped once `predicate` returns truthy. The predicate is
  10928. * invoked with three arguments: (value, index|key, collection).
  10929. *
  10930. * @static
  10931. * @memberOf _
  10932. * @since 0.1.0
  10933. * @category Collection
  10934. * @param {Array|Object} collection The collection to iterate over.
  10935. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  10936. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  10937. * @returns {boolean} Returns `true` if any element passes the predicate check,
  10938. * else `false`.
  10939. * @example
  10940. *
  10941. * _.some([null, 0, 'yes', false], Boolean);
  10942. * // => true
  10943. *
  10944. * var users = [
  10945. * { 'user': 'barney', 'active': true },
  10946. * { 'user': 'fred', 'active': false }
  10947. * ];
  10948. *
  10949. * // The `_.matches` iteratee shorthand.
  10950. * _.some(users, { 'user': 'barney', 'active': false });
  10951. * // => false
  10952. *
  10953. * // The `_.matchesProperty` iteratee shorthand.
  10954. * _.some(users, ['active', false]);
  10955. * // => true
  10956. *
  10957. * // The `_.property` iteratee shorthand.
  10958. * _.some(users, 'active');
  10959. * // => true
  10960. */
  10961. function some(collection, predicate, guard) {
  10962. var func = isArray(collection) ? arraySome : baseSome;
  10963. if (guard && isIterateeCall(collection, predicate, guard)) {
  10964. predicate = undefined;
  10965. }
  10966. return func(collection, getIteratee(predicate, 3));
  10967. }
  10968. /**
  10969. * Creates an array of elements, sorted in ascending order by the results of
  10970. * running each element in a collection thru each iteratee. This method
  10971. * performs a stable sort, that is, it preserves the original sort order of
  10972. * equal elements. The iteratees are invoked with one argument: (value).
  10973. *
  10974. * @static
  10975. * @memberOf _
  10976. * @since 0.1.0
  10977. * @category Collection
  10978. * @param {Array|Object} collection The collection to iterate over.
  10979. * @param {...(Function|Function[])} [iteratees=[_.identity]]
  10980. * The iteratees to sort by.
  10981. * @returns {Array} Returns the new sorted array.
  10982. * @example
  10983. *
  10984. * var users = [
  10985. * { 'user': 'fred', 'age': 48 },
  10986. * { 'user': 'barney', 'age': 36 },
  10987. * { 'user': 'fred', 'age': 30 },
  10988. * { 'user': 'barney', 'age': 34 }
  10989. * ];
  10990. *
  10991. * _.sortBy(users, [function(o) { return o.user; }]);
  10992. * // => objects for [['barney', 36], ['barney', 34], ['fred', 48], ['fred', 30]]
  10993. *
  10994. * _.sortBy(users, ['user', 'age']);
  10995. * // => objects for [['barney', 34], ['barney', 36], ['fred', 30], ['fred', 48]]
  10996. */
  10997. var sortBy = baseRest(function(collection, iteratees) {
  10998. if (collection == null) {
  10999. return [];
  11000. }
  11001. var length = iteratees.length;
  11002. if (length > 1 && isIterateeCall(collection, iteratees[0], iteratees[1])) {
  11003. iteratees = [];
  11004. } else if (length > 2 && isIterateeCall(iteratees[0], iteratees[1], iteratees[2])) {
  11005. iteratees = [iteratees[0]];
  11006. }
  11007. return baseOrderBy(collection, baseFlatten(iteratees, 1), []);
  11008. });
  11009. /*------------------------------------------------------------------------*/
  11010. /**
  11011. * Gets the timestamp of the number of milliseconds that have elapsed since
  11012. * the Unix epoch (1 January 1970 00:00:00 UTC).
  11013. *
  11014. * @static
  11015. * @memberOf _
  11016. * @since 2.4.0
  11017. * @category Date
  11018. * @returns {number} Returns the timestamp.
  11019. * @example
  11020. *
  11021. * _.defer(function(stamp) {
  11022. * console.log(_.now() - stamp);
  11023. * }, _.now());
  11024. * // => Logs the number of milliseconds it took for the deferred invocation.
  11025. */
  11026. var now = ctxNow || function() {
  11027. return root.Date.now();
  11028. };
  11029. /*------------------------------------------------------------------------*/
  11030. /**
  11031. * The opposite of `_.before`; this method creates a function that invokes
  11032. * `func` once it's called `n` or more times.
  11033. *
  11034. * @static
  11035. * @memberOf _
  11036. * @since 0.1.0
  11037. * @category Function
  11038. * @param {number} n The number of calls before `func` is invoked.
  11039. * @param {Function} func The function to restrict.
  11040. * @returns {Function} Returns the new restricted function.
  11041. * @example
  11042. *
  11043. * var saves = ['profile', 'settings'];
  11044. *
  11045. * var done = _.after(saves.length, function() {
  11046. * console.log('done saving!');
  11047. * });
  11048. *
  11049. * _.forEach(saves, function(type) {
  11050. * asyncSave({ 'type': type, 'complete': done });
  11051. * });
  11052. * // => Logs 'done saving!' after the two async saves have completed.
  11053. */
  11054. function after(n, func) {
  11055. if (typeof func != 'function') {
  11056. throw new TypeError(FUNC_ERROR_TEXT);
  11057. }
  11058. n = toInteger(n);
  11059. return function() {
  11060. if (--n < 1) {
  11061. return func.apply(this, arguments);
  11062. }
  11063. };
  11064. }
  11065. /**
  11066. * Creates a function that invokes `func`, with up to `n` arguments,
  11067. * ignoring any additional arguments.
  11068. *
  11069. * @static
  11070. * @memberOf _
  11071. * @since 3.0.0
  11072. * @category Function
  11073. * @param {Function} func The function to cap arguments for.
  11074. * @param {number} [n=func.length] The arity cap.
  11075. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  11076. * @returns {Function} Returns the new capped function.
  11077. * @example
  11078. *
  11079. * _.map(['6', '8', '10'], _.ary(parseInt, 1));
  11080. * // => [6, 8, 10]
  11081. */
  11082. function ary(func, n, guard) {
  11083. n = guard ? undefined : n;
  11084. n = (func && n == null) ? func.length : n;
  11085. return createWrap(func, WRAP_ARY_FLAG, undefined, undefined, undefined, undefined, n);
  11086. }
  11087. /**
  11088. * Creates a function that invokes `func`, with the `this` binding and arguments
  11089. * of the created function, while it's called less than `n` times. Subsequent
  11090. * calls to the created function return the result of the last `func` invocation.
  11091. *
  11092. * @static
  11093. * @memberOf _
  11094. * @since 3.0.0
  11095. * @category Function
  11096. * @param {number} n The number of calls at which `func` is no longer invoked.
  11097. * @param {Function} func The function to restrict.
  11098. * @returns {Function} Returns the new restricted function.
  11099. * @example
  11100. *
  11101. * jQuery(element).on('click', _.before(5, addContactToList));
  11102. * // => Allows adding up to 4 contacts to the list.
  11103. */
  11104. function before(n, func) {
  11105. var result;
  11106. if (typeof func != 'function') {
  11107. throw new TypeError(FUNC_ERROR_TEXT);
  11108. }
  11109. n = toInteger(n);
  11110. return function() {
  11111. if (--n > 0) {
  11112. result = func.apply(this, arguments);
  11113. }
  11114. if (n <= 1) {
  11115. func = undefined;
  11116. }
  11117. return result;
  11118. };
  11119. }
  11120. /**
  11121. * Creates a function that invokes `func` with the `this` binding of `thisArg`
  11122. * and `partials` prepended to the arguments it receives.
  11123. *
  11124. * The `_.bind.placeholder` value, which defaults to `_` in monolithic builds,
  11125. * may be used as a placeholder for partially applied arguments.
  11126. *
  11127. * **Note:** Unlike native `Function#bind`, this method doesn't set the "length"
  11128. * property of bound functions.
  11129. *
  11130. * @static
  11131. * @memberOf _
  11132. * @since 0.1.0
  11133. * @category Function
  11134. * @param {Function} func The function to bind.
  11135. * @param {*} thisArg The `this` binding of `func`.
  11136. * @param {...*} [partials] The arguments to be partially applied.
  11137. * @returns {Function} Returns the new bound function.
  11138. * @example
  11139. *
  11140. * function greet(greeting, punctuation) {
  11141. * return greeting + ' ' + this.user + punctuation;
  11142. * }
  11143. *
  11144. * var object = { 'user': 'fred' };
  11145. *
  11146. * var bound = _.bind(greet, object, 'hi');
  11147. * bound('!');
  11148. * // => 'hi fred!'
  11149. *
  11150. * // Bound with placeholders.
  11151. * var bound = _.bind(greet, object, _, '!');
  11152. * bound('hi');
  11153. * // => 'hi fred!'
  11154. */
  11155. var bind = baseRest(function(func, thisArg, partials) {
  11156. var bitmask = WRAP_BIND_FLAG;
  11157. if (partials.length) {
  11158. var holders = replaceHolders(partials, getHolder(bind));
  11159. bitmask |= WRAP_PARTIAL_FLAG;
  11160. }
  11161. return createWrap(func, bitmask, thisArg, partials, holders);
  11162. });
  11163. /**
  11164. * Creates a function that invokes the method at `object[key]` with `partials`
  11165. * prepended to the arguments it receives.
  11166. *
  11167. * This method differs from `_.bind` by allowing bound functions to reference
  11168. * methods that may be redefined or don't yet exist. See
  11169. * [Peter Michaux's article](http://peter.michaux.ca/articles/lazy-function-definition-pattern)
  11170. * for more details.
  11171. *
  11172. * The `_.bindKey.placeholder` value, which defaults to `_` in monolithic
  11173. * builds, may be used as a placeholder for partially applied arguments.
  11174. *
  11175. * @static
  11176. * @memberOf _
  11177. * @since 0.10.0
  11178. * @category Function
  11179. * @param {Object} object The object to invoke the method on.
  11180. * @param {string} key The key of the method.
  11181. * @param {...*} [partials] The arguments to be partially applied.
  11182. * @returns {Function} Returns the new bound function.
  11183. * @example
  11184. *
  11185. * var object = {
  11186. * 'user': 'fred',
  11187. * 'greet': function(greeting, punctuation) {
  11188. * return greeting + ' ' + this.user + punctuation;
  11189. * }
  11190. * };
  11191. *
  11192. * var bound = _.bindKey(object, 'greet', 'hi');
  11193. * bound('!');
  11194. * // => 'hi fred!'
  11195. *
  11196. * object.greet = function(greeting, punctuation) {
  11197. * return greeting + 'ya ' + this.user + punctuation;
  11198. * };
  11199. *
  11200. * bound('!');
  11201. * // => 'hiya fred!'
  11202. *
  11203. * // Bound with placeholders.
  11204. * var bound = _.bindKey(object, 'greet', _, '!');
  11205. * bound('hi');
  11206. * // => 'hiya fred!'
  11207. */
  11208. var bindKey = baseRest(function(object, key, partials) {
  11209. var bitmask = WRAP_BIND_FLAG | WRAP_BIND_KEY_FLAG;
  11210. if (partials.length) {
  11211. var holders = replaceHolders(partials, getHolder(bindKey));
  11212. bitmask |= WRAP_PARTIAL_FLAG;
  11213. }
  11214. return createWrap(key, bitmask, object, partials, holders);
  11215. });
  11216. /**
  11217. * Creates a function that accepts arguments of `func` and either invokes
  11218. * `func` returning its result, if at least `arity` number of arguments have
  11219. * been provided, or returns a function that accepts the remaining `func`
  11220. * arguments, and so on. The arity of `func` may be specified if `func.length`
  11221. * is not sufficient.
  11222. *
  11223. * The `_.curry.placeholder` value, which defaults to `_` in monolithic builds,
  11224. * may be used as a placeholder for provided arguments.
  11225. *
  11226. * **Note:** This method doesn't set the "length" property of curried functions.
  11227. *
  11228. * @static
  11229. * @memberOf _
  11230. * @since 2.0.0
  11231. * @category Function
  11232. * @param {Function} func The function to curry.
  11233. * @param {number} [arity=func.length] The arity of `func`.
  11234. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  11235. * @returns {Function} Returns the new curried function.
  11236. * @example
  11237. *
  11238. * var abc = function(a, b, c) {
  11239. * return [a, b, c];
  11240. * };
  11241. *
  11242. * var curried = _.curry(abc);
  11243. *
  11244. * curried(1)(2)(3);
  11245. * // => [1, 2, 3]
  11246. *
  11247. * curried(1, 2)(3);
  11248. * // => [1, 2, 3]
  11249. *
  11250. * curried(1, 2, 3);
  11251. * // => [1, 2, 3]
  11252. *
  11253. * // Curried with placeholders.
  11254. * curried(1)(_, 3)(2);
  11255. * // => [1, 2, 3]
  11256. */
  11257. function curry(func, arity, guard) {
  11258. arity = guard ? undefined : arity;
  11259. var result = createWrap(func, WRAP_CURRY_FLAG, undefined, undefined, undefined, undefined, undefined, arity);
  11260. result.placeholder = curry.placeholder;
  11261. return result;
  11262. }
  11263. /**
  11264. * This method is like `_.curry` except that arguments are applied to `func`
  11265. * in the manner of `_.partialRight` instead of `_.partial`.
  11266. *
  11267. * The `_.curryRight.placeholder` value, which defaults to `_` in monolithic
  11268. * builds, may be used as a placeholder for provided arguments.
  11269. *
  11270. * **Note:** This method doesn't set the "length" property of curried functions.
  11271. *
  11272. * @static
  11273. * @memberOf _
  11274. * @since 3.0.0
  11275. * @category Function
  11276. * @param {Function} func The function to curry.
  11277. * @param {number} [arity=func.length] The arity of `func`.
  11278. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  11279. * @returns {Function} Returns the new curried function.
  11280. * @example
  11281. *
  11282. * var abc = function(a, b, c) {
  11283. * return [a, b, c];
  11284. * };
  11285. *
  11286. * var curried = _.curryRight(abc);
  11287. *
  11288. * curried(3)(2)(1);
  11289. * // => [1, 2, 3]
  11290. *
  11291. * curried(2, 3)(1);
  11292. * // => [1, 2, 3]
  11293. *
  11294. * curried(1, 2, 3);
  11295. * // => [1, 2, 3]
  11296. *
  11297. * // Curried with placeholders.
  11298. * curried(3)(1, _)(2);
  11299. * // => [1, 2, 3]
  11300. */
  11301. function curryRight(func, arity, guard) {
  11302. arity = guard ? undefined : arity;
  11303. var result = createWrap(func, WRAP_CURRY_RIGHT_FLAG, undefined, undefined, undefined, undefined, undefined, arity);
  11304. result.placeholder = curryRight.placeholder;
  11305. return result;
  11306. }
  11307. /**
  11308. * Creates a debounced function that delays invoking `func` until after `wait`
  11309. * milliseconds have elapsed since the last time the debounced function was
  11310. * invoked. The debounced function comes with a `cancel` method to cancel
  11311. * delayed `func` invocations and a `flush` method to immediately invoke them.
  11312. * Provide `options` to indicate whether `func` should be invoked on the
  11313. * leading and/or trailing edge of the `wait` timeout. The `func` is invoked
  11314. * with the last arguments provided to the debounced function. Subsequent
  11315. * calls to the debounced function return the result of the last `func`
  11316. * invocation.
  11317. *
  11318. * **Note:** If `leading` and `trailing` options are `true`, `func` is
  11319. * invoked on the trailing edge of the timeout only if the debounced function
  11320. * is invoked more than once during the `wait` timeout.
  11321. *
  11322. * If `wait` is `0` and `leading` is `false`, `func` invocation is deferred
  11323. * until to the next tick, similar to `setTimeout` with a timeout of `0`.
  11324. *
  11325. * See [David Corbacho's article](https://css-tricks.com/debouncing-throttling-explained-examples/)
  11326. * for details over the differences between `_.debounce` and `_.throttle`.
  11327. *
  11328. * @static
  11329. * @memberOf _
  11330. * @since 0.1.0
  11331. * @category Function
  11332. * @param {Function} func The function to debounce.
  11333. * @param {number} [wait=0] The number of milliseconds to delay.
  11334. * @param {Object} [options={}] The options object.
  11335. * @param {boolean} [options.leading=false]
  11336. * Specify invoking on the leading edge of the timeout.
  11337. * @param {number} [options.maxWait]
  11338. * The maximum time `func` is allowed to be delayed before it's invoked.
  11339. * @param {boolean} [options.trailing=true]
  11340. * Specify invoking on the trailing edge of the timeout.
  11341. * @returns {Function} Returns the new debounced function.
  11342. * @example
  11343. *
  11344. * // Avoid costly calculations while the window size is in flux.
  11345. * jQuery(window).on('resize', _.debounce(calculateLayout, 150));
  11346. *
  11347. * // Invoke `sendMail` when clicked, debouncing subsequent calls.
  11348. * jQuery(element).on('click', _.debounce(sendMail, 300, {
  11349. * 'leading': true,
  11350. * 'trailing': false
  11351. * }));
  11352. *
  11353. * // Ensure `batchLog` is invoked once after 1 second of debounced calls.
  11354. * var debounced = _.debounce(batchLog, 250, { 'maxWait': 1000 });
  11355. * var source = new EventSource('/stream');
  11356. * jQuery(source).on('message', debounced);
  11357. *
  11358. * // Cancel the trailing debounced invocation.
  11359. * jQuery(window).on('popstate', debounced.cancel);
  11360. */
  11361. function debounce(func, wait, options) {
  11362. var lastArgs,
  11363. lastThis,
  11364. maxWait,
  11365. result,
  11366. timerId,
  11367. lastCallTime,
  11368. lastInvokeTime = 0,
  11369. leading = false,
  11370. maxing = false,
  11371. trailing = true;
  11372. if (typeof func != 'function') {
  11373. throw new TypeError(FUNC_ERROR_TEXT);
  11374. }
  11375. wait = toNumber(wait) || 0;
  11376. if (isObject(options)) {
  11377. leading = !!options.leading;
  11378. maxing = 'maxWait' in options;
  11379. maxWait = maxing ? nativeMax(toNumber(options.maxWait) || 0, wait) : maxWait;
  11380. trailing = 'trailing' in options ? !!options.trailing : trailing;
  11381. }
  11382. function invokeFunc(time) {
  11383. var args = lastArgs,
  11384. thisArg = lastThis;
  11385. lastArgs = lastThis = undefined;
  11386. lastInvokeTime = time;
  11387. result = func.apply(thisArg, args);
  11388. return result;
  11389. }
  11390. function leadingEdge(time) {
  11391. // Reset any `maxWait` timer.
  11392. lastInvokeTime = time;
  11393. // Start the timer for the trailing edge.
  11394. timerId = setTimeout(timerExpired, wait);
  11395. // Invoke the leading edge.
  11396. return leading ? invokeFunc(time) : result;
  11397. }
  11398. function remainingWait(time) {
  11399. var timeSinceLastCall = time - lastCallTime,
  11400. timeSinceLastInvoke = time - lastInvokeTime,
  11401. timeWaiting = wait - timeSinceLastCall;
  11402. return maxing
  11403. ? nativeMin(timeWaiting, maxWait - timeSinceLastInvoke)
  11404. : timeWaiting;
  11405. }
  11406. function shouldInvoke(time) {
  11407. var timeSinceLastCall = time - lastCallTime,
  11408. timeSinceLastInvoke = time - lastInvokeTime;
  11409. // Either this is the first call, activity has stopped and we're at the
  11410. // trailing edge, the system time has gone backwards and we're treating
  11411. // it as the trailing edge, or we've hit the `maxWait` limit.
  11412. return (lastCallTime === undefined || (timeSinceLastCall >= wait) ||
  11413. (timeSinceLastCall < 0) || (maxing && timeSinceLastInvoke >= maxWait));
  11414. }
  11415. function timerExpired() {
  11416. var time = now();
  11417. if (shouldInvoke(time)) {
  11418. return trailingEdge(time);
  11419. }
  11420. // Restart the timer.
  11421. timerId = setTimeout(timerExpired, remainingWait(time));
  11422. }
  11423. function trailingEdge(time) {
  11424. timerId = undefined;
  11425. // Only invoke if we have `lastArgs` which means `func` has been
  11426. // debounced at least once.
  11427. if (trailing && lastArgs) {
  11428. return invokeFunc(time);
  11429. }
  11430. lastArgs = lastThis = undefined;
  11431. return result;
  11432. }
  11433. function cancel() {
  11434. if (timerId !== undefined) {
  11435. clearTimeout(timerId);
  11436. }
  11437. lastInvokeTime = 0;
  11438. lastArgs = lastCallTime = lastThis = timerId = undefined;
  11439. }
  11440. function flush() {
  11441. return timerId === undefined ? result : trailingEdge(now());
  11442. }
  11443. function debounced() {
  11444. var time = now(),
  11445. isInvoking = shouldInvoke(time);
  11446. lastArgs = arguments;
  11447. lastThis = this;
  11448. lastCallTime = time;
  11449. if (isInvoking) {
  11450. if (timerId === undefined) {
  11451. return leadingEdge(lastCallTime);
  11452. }
  11453. if (maxing) {
  11454. // Handle invocations in a tight loop.
  11455. clearTimeout(timerId);
  11456. timerId = setTimeout(timerExpired, wait);
  11457. return invokeFunc(lastCallTime);
  11458. }
  11459. }
  11460. if (timerId === undefined) {
  11461. timerId = setTimeout(timerExpired, wait);
  11462. }
  11463. return result;
  11464. }
  11465. debounced.cancel = cancel;
  11466. debounced.flush = flush;
  11467. return debounced;
  11468. }
  11469. /**
  11470. * Defers invoking the `func` until the current call stack has cleared. Any
  11471. * additional arguments are provided to `func` when it's invoked.
  11472. *
  11473. * @static
  11474. * @memberOf _
  11475. * @since 0.1.0
  11476. * @category Function
  11477. * @param {Function} func The function to defer.
  11478. * @param {...*} [args] The arguments to invoke `func` with.
  11479. * @returns {number} Returns the timer id.
  11480. * @example
  11481. *
  11482. * _.defer(function(text) {
  11483. * console.log(text);
  11484. * }, 'deferred');
  11485. * // => Logs 'deferred' after one millisecond.
  11486. */
  11487. var defer = baseRest(function(func, args) {
  11488. return baseDelay(func, 1, args);
  11489. });
  11490. /**
  11491. * Invokes `func` after `wait` milliseconds. Any additional arguments are
  11492. * provided to `func` when it's invoked.
  11493. *
  11494. * @static
  11495. * @memberOf _
  11496. * @since 0.1.0
  11497. * @category Function
  11498. * @param {Function} func The function to delay.
  11499. * @param {number} wait The number of milliseconds to delay invocation.
  11500. * @param {...*} [args] The arguments to invoke `func` with.
  11501. * @returns {number} Returns the timer id.
  11502. * @example
  11503. *
  11504. * _.delay(function(text) {
  11505. * console.log(text);
  11506. * }, 1000, 'later');
  11507. * // => Logs 'later' after one second.
  11508. */
  11509. var delay = baseRest(function(func, wait, args) {
  11510. return baseDelay(func, toNumber(wait) || 0, args);
  11511. });
  11512. /**
  11513. * Creates a function that invokes `func` with arguments reversed.
  11514. *
  11515. * @static
  11516. * @memberOf _
  11517. * @since 4.0.0
  11518. * @category Function
  11519. * @param {Function} func The function to flip arguments for.
  11520. * @returns {Function} Returns the new flipped function.
  11521. * @example
  11522. *
  11523. * var flipped = _.flip(function() {
  11524. * return _.toArray(arguments);
  11525. * });
  11526. *
  11527. * flipped('a', 'b', 'c', 'd');
  11528. * // => ['d', 'c', 'b', 'a']
  11529. */
  11530. function flip(func) {
  11531. return createWrap(func, WRAP_FLIP_FLAG);
  11532. }
  11533. /**
  11534. * Creates a function that memoizes the result of `func`. If `resolver` is
  11535. * provided, it determines the cache key for storing the result based on the
  11536. * arguments provided to the memoized function. By default, the first argument
  11537. * provided to the memoized function is used as the map cache key. The `func`
  11538. * is invoked with the `this` binding of the memoized function.
  11539. *
  11540. * **Note:** The cache is exposed as the `cache` property on the memoized
  11541. * function. Its creation may be customized by replacing the `_.memoize.Cache`
  11542. * constructor with one whose instances implement the
  11543. * [`Map`](http://ecma-international.org/ecma-262/7.0/#sec-properties-of-the-map-prototype-object)
  11544. * method interface of `clear`, `delete`, `get`, `has`, and `set`.
  11545. *
  11546. * @static
  11547. * @memberOf _
  11548. * @since 0.1.0
  11549. * @category Function
  11550. * @param {Function} func The function to have its output memoized.
  11551. * @param {Function} [resolver] The function to resolve the cache key.
  11552. * @returns {Function} Returns the new memoized function.
  11553. * @example
  11554. *
  11555. * var object = { 'a': 1, 'b': 2 };
  11556. * var other = { 'c': 3, 'd': 4 };
  11557. *
  11558. * var values = _.memoize(_.values);
  11559. * values(object);
  11560. * // => [1, 2]
  11561. *
  11562. * values(other);
  11563. * // => [3, 4]
  11564. *
  11565. * object.a = 2;
  11566. * values(object);
  11567. * // => [1, 2]
  11568. *
  11569. * // Modify the result cache.
  11570. * values.cache.set(object, ['a', 'b']);
  11571. * values(object);
  11572. * // => ['a', 'b']
  11573. *
  11574. * // Replace `_.memoize.Cache`.
  11575. * _.memoize.Cache = WeakMap;
  11576. */
  11577. function memoize(func, resolver) {
  11578. if (typeof func != 'function' || (resolver != null && typeof resolver != 'function')) {
  11579. throw new TypeError(FUNC_ERROR_TEXT);
  11580. }
  11581. var memoized = function() {
  11582. var args = arguments,
  11583. key = resolver ? resolver.apply(this, args) : args[0],
  11584. cache = memoized.cache;
  11585. if (cache.has(key)) {
  11586. return cache.get(key);
  11587. }
  11588. var result = func.apply(this, args);
  11589. memoized.cache = cache.set(key, result) || cache;
  11590. return result;
  11591. };
  11592. memoized.cache = new (memoize.Cache || MapCache);
  11593. return memoized;
  11594. }
  11595. // Expose `MapCache`.
  11596. memoize.Cache = MapCache;
  11597. /**
  11598. * Creates a function that negates the result of the predicate `func`. The
  11599. * `func` predicate is invoked with the `this` binding and arguments of the
  11600. * created function.
  11601. *
  11602. * @static
  11603. * @memberOf _
  11604. * @since 3.0.0
  11605. * @category Function
  11606. * @param {Function} predicate The predicate to negate.
  11607. * @returns {Function} Returns the new negated function.
  11608. * @example
  11609. *
  11610. * function isEven(n) {
  11611. * return n % 2 == 0;
  11612. * }
  11613. *
  11614. * _.filter([1, 2, 3, 4, 5, 6], _.negate(isEven));
  11615. * // => [1, 3, 5]
  11616. */
  11617. function negate(predicate) {
  11618. if (typeof predicate != 'function') {
  11619. throw new TypeError(FUNC_ERROR_TEXT);
  11620. }
  11621. return function() {
  11622. var args = arguments;
  11623. switch (args.length) {
  11624. case 0: return !predicate.call(this);
  11625. case 1: return !predicate.call(this, args[0]);
  11626. case 2: return !predicate.call(this, args[0], args[1]);
  11627. case 3: return !predicate.call(this, args[0], args[1], args[2]);
  11628. }
  11629. return !predicate.apply(this, args);
  11630. };
  11631. }
  11632. /**
  11633. * Creates a function that is restricted to invoking `func` once. Repeat calls
  11634. * to the function return the value of the first invocation. The `func` is
  11635. * invoked with the `this` binding and arguments of the created function.
  11636. *
  11637. * @static
  11638. * @memberOf _
  11639. * @since 0.1.0
  11640. * @category Function
  11641. * @param {Function} func The function to restrict.
  11642. * @returns {Function} Returns the new restricted function.
  11643. * @example
  11644. *
  11645. * var initialize = _.once(createApplication);
  11646. * initialize();
  11647. * initialize();
  11648. * // => `createApplication` is invoked once
  11649. */
  11650. function once(func) {
  11651. return before(2, func);
  11652. }
  11653. /**
  11654. * Creates a function that invokes `func` with its arguments transformed.
  11655. *
  11656. * @static
  11657. * @since 4.0.0
  11658. * @memberOf _
  11659. * @category Function
  11660. * @param {Function} func The function to wrap.
  11661. * @param {...(Function|Function[])} [transforms=[_.identity]]
  11662. * The argument transforms.
  11663. * @returns {Function} Returns the new function.
  11664. * @example
  11665. *
  11666. * function doubled(n) {
  11667. * return n * 2;
  11668. * }
  11669. *
  11670. * function square(n) {
  11671. * return n * n;
  11672. * }
  11673. *
  11674. * var func = _.overArgs(function(x, y) {
  11675. * return [x, y];
  11676. * }, [square, doubled]);
  11677. *
  11678. * func(9, 3);
  11679. * // => [81, 6]
  11680. *
  11681. * func(10, 5);
  11682. * // => [100, 10]
  11683. */
  11684. var overArgs = castRest(function(func, transforms) {
  11685. transforms = (transforms.length == 1 && isArray(transforms[0]))
  11686. ? arrayMap(transforms[0], baseUnary(getIteratee()))
  11687. : arrayMap(baseFlatten(transforms, 1), baseUnary(getIteratee()));
  11688. var funcsLength = transforms.length;
  11689. return baseRest(function(args) {
  11690. var index = -1,
  11691. length = nativeMin(args.length, funcsLength);
  11692. while (++index < length) {
  11693. args[index] = transforms[index].call(this, args[index]);
  11694. }
  11695. return apply(func, this, args);
  11696. });
  11697. });
  11698. /**
  11699. * Creates a function that invokes `func` with `partials` prepended to the
  11700. * arguments it receives. This method is like `_.bind` except it does **not**
  11701. * alter the `this` binding.
  11702. *
  11703. * The `_.partial.placeholder` value, which defaults to `_` in monolithic
  11704. * builds, may be used as a placeholder for partially applied arguments.
  11705. *
  11706. * **Note:** This method doesn't set the "length" property of partially
  11707. * applied functions.
  11708. *
  11709. * @static
  11710. * @memberOf _
  11711. * @since 0.2.0
  11712. * @category Function
  11713. * @param {Function} func The function to partially apply arguments to.
  11714. * @param {...*} [partials] The arguments to be partially applied.
  11715. * @returns {Function} Returns the new partially applied function.
  11716. * @example
  11717. *
  11718. * function greet(greeting, name) {
  11719. * return greeting + ' ' + name;
  11720. * }
  11721. *
  11722. * var sayHelloTo = _.partial(greet, 'hello');
  11723. * sayHelloTo('fred');
  11724. * // => 'hello fred'
  11725. *
  11726. * // Partially applied with placeholders.
  11727. * var greetFred = _.partial(greet, _, 'fred');
  11728. * greetFred('hi');
  11729. * // => 'hi fred'
  11730. */
  11731. var partial = baseRest(function(func, partials) {
  11732. var holders = replaceHolders(partials, getHolder(partial));
  11733. return createWrap(func, WRAP_PARTIAL_FLAG, undefined, partials, holders);
  11734. });
  11735. /**
  11736. * This method is like `_.partial` except that partially applied arguments
  11737. * are appended to the arguments it receives.
  11738. *
  11739. * The `_.partialRight.placeholder` value, which defaults to `_` in monolithic
  11740. * builds, may be used as a placeholder for partially applied arguments.
  11741. *
  11742. * **Note:** This method doesn't set the "length" property of partially
  11743. * applied functions.
  11744. *
  11745. * @static
  11746. * @memberOf _
  11747. * @since 1.0.0
  11748. * @category Function
  11749. * @param {Function} func The function to partially apply arguments to.
  11750. * @param {...*} [partials] The arguments to be partially applied.
  11751. * @returns {Function} Returns the new partially applied function.
  11752. * @example
  11753. *
  11754. * function greet(greeting, name) {
  11755. * return greeting + ' ' + name;
  11756. * }
  11757. *
  11758. * var greetFred = _.partialRight(greet, 'fred');
  11759. * greetFred('hi');
  11760. * // => 'hi fred'
  11761. *
  11762. * // Partially applied with placeholders.
  11763. * var sayHelloTo = _.partialRight(greet, 'hello', _);
  11764. * sayHelloTo('fred');
  11765. * // => 'hello fred'
  11766. */
  11767. var partialRight = baseRest(function(func, partials) {
  11768. var holders = replaceHolders(partials, getHolder(partialRight));
  11769. return createWrap(func, WRAP_PARTIAL_RIGHT_FLAG, undefined, partials, holders);
  11770. });
  11771. /**
  11772. * Creates a function that invokes `func` with arguments arranged according
  11773. * to the specified `indexes` where the argument value at the first index is
  11774. * provided as the first argument, the argument value at the second index is
  11775. * provided as the second argument, and so on.
  11776. *
  11777. * @static
  11778. * @memberOf _
  11779. * @since 3.0.0
  11780. * @category Function
  11781. * @param {Function} func The function to rearrange arguments for.
  11782. * @param {...(number|number[])} indexes The arranged argument indexes.
  11783. * @returns {Function} Returns the new function.
  11784. * @example
  11785. *
  11786. * var rearged = _.rearg(function(a, b, c) {
  11787. * return [a, b, c];
  11788. * }, [2, 0, 1]);
  11789. *
  11790. * rearged('b', 'c', 'a')
  11791. * // => ['a', 'b', 'c']
  11792. */
  11793. var rearg = flatRest(function(func, indexes) {
  11794. return createWrap(func, WRAP_REARG_FLAG, undefined, undefined, undefined, indexes);
  11795. });
  11796. /**
  11797. * Creates a function that invokes `func` with the `this` binding of the
  11798. * created function and arguments from `start` and beyond provided as
  11799. * an array.
  11800. *
  11801. * **Note:** This method is based on the
  11802. * [rest parameter](https://mdn.io/rest_parameters).
  11803. *
  11804. * @static
  11805. * @memberOf _
  11806. * @since 4.0.0
  11807. * @category Function
  11808. * @param {Function} func The function to apply a rest parameter to.
  11809. * @param {number} [start=func.length-1] The start position of the rest parameter.
  11810. * @returns {Function} Returns the new function.
  11811. * @example
  11812. *
  11813. * var say = _.rest(function(what, names) {
  11814. * return what + ' ' + _.initial(names).join(', ') +
  11815. * (_.size(names) > 1 ? ', & ' : '') + _.last(names);
  11816. * });
  11817. *
  11818. * say('hello', 'fred', 'barney', 'pebbles');
  11819. * // => 'hello fred, barney, & pebbles'
  11820. */
  11821. function rest(func, start) {
  11822. if (typeof func != 'function') {
  11823. throw new TypeError(FUNC_ERROR_TEXT);
  11824. }
  11825. start = start === undefined ? start : toInteger(start);
  11826. return baseRest(func, start);
  11827. }
  11828. /**
  11829. * Creates a function that invokes `func` with the `this` binding of the
  11830. * create function and an array of arguments much like
  11831. * [`Function#apply`](http://www.ecma-international.org/ecma-262/7.0/#sec-function.prototype.apply).
  11832. *
  11833. * **Note:** This method is based on the
  11834. * [spread operator](https://mdn.io/spread_operator).
  11835. *
  11836. * @static
  11837. * @memberOf _
  11838. * @since 3.2.0
  11839. * @category Function
  11840. * @param {Function} func The function to spread arguments over.
  11841. * @param {number} [start=0] The start position of the spread.
  11842. * @returns {Function} Returns the new function.
  11843. * @example
  11844. *
  11845. * var say = _.spread(function(who, what) {
  11846. * return who + ' says ' + what;
  11847. * });
  11848. *
  11849. * say(['fred', 'hello']);
  11850. * // => 'fred says hello'
  11851. *
  11852. * var numbers = Promise.all([
  11853. * Promise.resolve(40),
  11854. * Promise.resolve(36)
  11855. * ]);
  11856. *
  11857. * numbers.then(_.spread(function(x, y) {
  11858. * return x + y;
  11859. * }));
  11860. * // => a Promise of 76
  11861. */
  11862. function spread(func, start) {
  11863. if (typeof func != 'function') {
  11864. throw new TypeError(FUNC_ERROR_TEXT);
  11865. }
  11866. start = start == null ? 0 : nativeMax(toInteger(start), 0);
  11867. return baseRest(function(args) {
  11868. var array = args[start],
  11869. otherArgs = castSlice(args, 0, start);
  11870. if (array) {
  11871. arrayPush(otherArgs, array);
  11872. }
  11873. return apply(func, this, otherArgs);
  11874. });
  11875. }
  11876. /**
  11877. * Creates a throttled function that only invokes `func` at most once per
  11878. * every `wait` milliseconds. The throttled function comes with a `cancel`
  11879. * method to cancel delayed `func` invocations and a `flush` method to
  11880. * immediately invoke them. Provide `options` to indicate whether `func`
  11881. * should be invoked on the leading and/or trailing edge of the `wait`
  11882. * timeout. The `func` is invoked with the last arguments provided to the
  11883. * throttled function. Subsequent calls to the throttled function return the
  11884. * result of the last `func` invocation.
  11885. *
  11886. * **Note:** If `leading` and `trailing` options are `true`, `func` is
  11887. * invoked on the trailing edge of the timeout only if the throttled function
  11888. * is invoked more than once during the `wait` timeout.
  11889. *
  11890. * If `wait` is `0` and `leading` is `false`, `func` invocation is deferred
  11891. * until to the next tick, similar to `setTimeout` with a timeout of `0`.
  11892. *
  11893. * See [David Corbacho's article](https://css-tricks.com/debouncing-throttling-explained-examples/)
  11894. * for details over the differences between `_.throttle` and `_.debounce`.
  11895. *
  11896. * @static
  11897. * @memberOf _
  11898. * @since 0.1.0
  11899. * @category Function
  11900. * @param {Function} func The function to throttle.
  11901. * @param {number} [wait=0] The number of milliseconds to throttle invocations to.
  11902. * @param {Object} [options={}] The options object.
  11903. * @param {boolean} [options.leading=true]
  11904. * Specify invoking on the leading edge of the timeout.
  11905. * @param {boolean} [options.trailing=true]
  11906. * Specify invoking on the trailing edge of the timeout.
  11907. * @returns {Function} Returns the new throttled function.
  11908. * @example
  11909. *
  11910. * // Avoid excessively updating the position while scrolling.
  11911. * jQuery(window).on('scroll', _.throttle(updatePosition, 100));
  11912. *
  11913. * // Invoke `renewToken` when the click event is fired, but not more than once every 5 minutes.
  11914. * var throttled = _.throttle(renewToken, 300000, { 'trailing': false });
  11915. * jQuery(element).on('click', throttled);
  11916. *
  11917. * // Cancel the trailing throttled invocation.
  11918. * jQuery(window).on('popstate', throttled.cancel);
  11919. */
  11920. function throttle(func, wait, options) {
  11921. var leading = true,
  11922. trailing = true;
  11923. if (typeof func != 'function') {
  11924. throw new TypeError(FUNC_ERROR_TEXT);
  11925. }
  11926. if (isObject(options)) {
  11927. leading = 'leading' in options ? !!options.leading : leading;
  11928. trailing = 'trailing' in options ? !!options.trailing : trailing;
  11929. }
  11930. return debounce(func, wait, {
  11931. 'leading': leading,
  11932. 'maxWait': wait,
  11933. 'trailing': trailing
  11934. });
  11935. }
  11936. /**
  11937. * Creates a function that accepts up to one argument, ignoring any
  11938. * additional arguments.
  11939. *
  11940. * @static
  11941. * @memberOf _
  11942. * @since 4.0.0
  11943. * @category Function
  11944. * @param {Function} func The function to cap arguments for.
  11945. * @returns {Function} Returns the new capped function.
  11946. * @example
  11947. *
  11948. * _.map(['6', '8', '10'], _.unary(parseInt));
  11949. * // => [6, 8, 10]
  11950. */
  11951. function unary(func) {
  11952. return ary(func, 1);
  11953. }
  11954. /**
  11955. * Creates a function that provides `value` to `wrapper` as its first
  11956. * argument. Any additional arguments provided to the function are appended
  11957. * to those provided to the `wrapper`. The wrapper is invoked with the `this`
  11958. * binding of the created function.
  11959. *
  11960. * @static
  11961. * @memberOf _
  11962. * @since 0.1.0
  11963. * @category Function
  11964. * @param {*} value The value to wrap.
  11965. * @param {Function} [wrapper=identity] The wrapper function.
  11966. * @returns {Function} Returns the new function.
  11967. * @example
  11968. *
  11969. * var p = _.wrap(_.escape, function(func, text) {
  11970. * return '<p>' + func(text) + '</p>';
  11971. * });
  11972. *
  11973. * p('fred, barney, & pebbles');
  11974. * // => '<p>fred, barney, &amp; pebbles</p>'
  11975. */
  11976. function wrap(value, wrapper) {
  11977. return partial(castFunction(wrapper), value);
  11978. }
  11979. /*------------------------------------------------------------------------*/
  11980. /**
  11981. * Casts `value` as an array if it's not one.
  11982. *
  11983. * @static
  11984. * @memberOf _
  11985. * @since 4.4.0
  11986. * @category Lang
  11987. * @param {*} value The value to inspect.
  11988. * @returns {Array} Returns the cast array.
  11989. * @example
  11990. *
  11991. * _.castArray(1);
  11992. * // => [1]
  11993. *
  11994. * _.castArray({ 'a': 1 });
  11995. * // => [{ 'a': 1 }]
  11996. *
  11997. * _.castArray('abc');
  11998. * // => ['abc']
  11999. *
  12000. * _.castArray(null);
  12001. * // => [null]
  12002. *
  12003. * _.castArray(undefined);
  12004. * // => [undefined]
  12005. *
  12006. * _.castArray();
  12007. * // => []
  12008. *
  12009. * var array = [1, 2, 3];
  12010. * console.log(_.castArray(array) === array);
  12011. * // => true
  12012. */
  12013. function castArray() {
  12014. if (!arguments.length) {
  12015. return [];
  12016. }
  12017. var value = arguments[0];
  12018. return isArray(value) ? value : [value];
  12019. }
  12020. /**
  12021. * Creates a shallow clone of `value`.
  12022. *
  12023. * **Note:** This method is loosely based on the
  12024. * [structured clone algorithm](https://mdn.io/Structured_clone_algorithm)
  12025. * and supports cloning arrays, array buffers, booleans, date objects, maps,
  12026. * numbers, `Object` objects, regexes, sets, strings, symbols, and typed
  12027. * arrays. The own enumerable properties of `arguments` objects are cloned
  12028. * as plain objects. An empty object is returned for uncloneable values such
  12029. * as error objects, functions, DOM nodes, and WeakMaps.
  12030. *
  12031. * @static
  12032. * @memberOf _
  12033. * @since 0.1.0
  12034. * @category Lang
  12035. * @param {*} value The value to clone.
  12036. * @returns {*} Returns the cloned value.
  12037. * @see _.cloneDeep
  12038. * @example
  12039. *
  12040. * var objects = [{ 'a': 1 }, { 'b': 2 }];
  12041. *
  12042. * var shallow = _.clone(objects);
  12043. * console.log(shallow[0] === objects[0]);
  12044. * // => true
  12045. */
  12046. function clone(value) {
  12047. return baseClone(value, CLONE_SYMBOLS_FLAG);
  12048. }
  12049. /**
  12050. * This method is like `_.clone` except that it accepts `customizer` which
  12051. * is invoked to produce the cloned value. If `customizer` returns `undefined`,
  12052. * cloning is handled by the method instead. The `customizer` is invoked with
  12053. * up to four arguments; (value [, index|key, object, stack]).
  12054. *
  12055. * @static
  12056. * @memberOf _
  12057. * @since 4.0.0
  12058. * @category Lang
  12059. * @param {*} value The value to clone.
  12060. * @param {Function} [customizer] The function to customize cloning.
  12061. * @returns {*} Returns the cloned value.
  12062. * @see _.cloneDeepWith
  12063. * @example
  12064. *
  12065. * function customizer(value) {
  12066. * if (_.isElement(value)) {
  12067. * return value.cloneNode(false);
  12068. * }
  12069. * }
  12070. *
  12071. * var el = _.cloneWith(document.body, customizer);
  12072. *
  12073. * console.log(el === document.body);
  12074. * // => false
  12075. * console.log(el.nodeName);
  12076. * // => 'BODY'
  12077. * console.log(el.childNodes.length);
  12078. * // => 0
  12079. */
  12080. function cloneWith(value, customizer) {
  12081. customizer = typeof customizer == 'function' ? customizer : undefined;
  12082. return baseClone(value, CLONE_SYMBOLS_FLAG, customizer);
  12083. }
  12084. /**
  12085. * This method is like `_.clone` except that it recursively clones `value`.
  12086. *
  12087. * @static
  12088. * @memberOf _
  12089. * @since 1.0.0
  12090. * @category Lang
  12091. * @param {*} value The value to recursively clone.
  12092. * @returns {*} Returns the deep cloned value.
  12093. * @see _.clone
  12094. * @example
  12095. *
  12096. * var objects = [{ 'a': 1 }, { 'b': 2 }];
  12097. *
  12098. * var deep = _.cloneDeep(objects);
  12099. * console.log(deep[0] === objects[0]);
  12100. * // => false
  12101. */
  12102. function cloneDeep(value) {
  12103. return baseClone(value, CLONE_DEEP_FLAG | CLONE_SYMBOLS_FLAG);
  12104. }
  12105. /**
  12106. * This method is like `_.cloneWith` except that it recursively clones `value`.
  12107. *
  12108. * @static
  12109. * @memberOf _
  12110. * @since 4.0.0
  12111. * @category Lang
  12112. * @param {*} value The value to recursively clone.
  12113. * @param {Function} [customizer] The function to customize cloning.
  12114. * @returns {*} Returns the deep cloned value.
  12115. * @see _.cloneWith
  12116. * @example
  12117. *
  12118. * function customizer(value) {
  12119. * if (_.isElement(value)) {
  12120. * return value.cloneNode(true);
  12121. * }
  12122. * }
  12123. *
  12124. * var el = _.cloneDeepWith(document.body, customizer);
  12125. *
  12126. * console.log(el === document.body);
  12127. * // => false
  12128. * console.log(el.nodeName);
  12129. * // => 'BODY'
  12130. * console.log(el.childNodes.length);
  12131. * // => 20
  12132. */
  12133. function cloneDeepWith(value, customizer) {
  12134. customizer = typeof customizer == 'function' ? customizer : undefined;
  12135. return baseClone(value, CLONE_DEEP_FLAG | CLONE_SYMBOLS_FLAG, customizer);
  12136. }
  12137. /**
  12138. * Checks if `object` conforms to `source` by invoking the predicate
  12139. * properties of `source` with the corresponding property values of `object`.
  12140. *
  12141. * **Note:** This method is equivalent to `_.conforms` when `source` is
  12142. * partially applied.
  12143. *
  12144. * @static
  12145. * @memberOf _
  12146. * @since 4.14.0
  12147. * @category Lang
  12148. * @param {Object} object The object to inspect.
  12149. * @param {Object} source The object of property predicates to conform to.
  12150. * @returns {boolean} Returns `true` if `object` conforms, else `false`.
  12151. * @example
  12152. *
  12153. * var object = { 'a': 1, 'b': 2 };
  12154. *
  12155. * _.conformsTo(object, { 'b': function(n) { return n > 1; } });
  12156. * // => true
  12157. *
  12158. * _.conformsTo(object, { 'b': function(n) { return n > 2; } });
  12159. * // => false
  12160. */
  12161. function conformsTo(object, source) {
  12162. return source == null || baseConformsTo(object, source, keys(source));
  12163. }
  12164. /**
  12165. * Performs a
  12166. * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
  12167. * comparison between two values to determine if they are equivalent.
  12168. *
  12169. * @static
  12170. * @memberOf _
  12171. * @since 4.0.0
  12172. * @category Lang
  12173. * @param {*} value The value to compare.
  12174. * @param {*} other The other value to compare.
  12175. * @returns {boolean} Returns `true` if the values are equivalent, else `false`.
  12176. * @example
  12177. *
  12178. * var object = { 'a': 1 };
  12179. * var other = { 'a': 1 };
  12180. *
  12181. * _.eq(object, object);
  12182. * // => true
  12183. *
  12184. * _.eq(object, other);
  12185. * // => false
  12186. *
  12187. * _.eq('a', 'a');
  12188. * // => true
  12189. *
  12190. * _.eq('a', Object('a'));
  12191. * // => false
  12192. *
  12193. * _.eq(NaN, NaN);
  12194. * // => true
  12195. */
  12196. function eq(value, other) {
  12197. return value === other || (value !== value && other !== other);
  12198. }
  12199. /**
  12200. * Checks if `value` is greater than `other`.
  12201. *
  12202. * @static
  12203. * @memberOf _
  12204. * @since 3.9.0
  12205. * @category Lang
  12206. * @param {*} value The value to compare.
  12207. * @param {*} other The other value to compare.
  12208. * @returns {boolean} Returns `true` if `value` is greater than `other`,
  12209. * else `false`.
  12210. * @see _.lt
  12211. * @example
  12212. *
  12213. * _.gt(3, 1);
  12214. * // => true
  12215. *
  12216. * _.gt(3, 3);
  12217. * // => false
  12218. *
  12219. * _.gt(1, 3);
  12220. * // => false
  12221. */
  12222. var gt = createRelationalOperation(baseGt);
  12223. /**
  12224. * Checks if `value` is greater than or equal to `other`.
  12225. *
  12226. * @static
  12227. * @memberOf _
  12228. * @since 3.9.0
  12229. * @category Lang
  12230. * @param {*} value The value to compare.
  12231. * @param {*} other The other value to compare.
  12232. * @returns {boolean} Returns `true` if `value` is greater than or equal to
  12233. * `other`, else `false`.
  12234. * @see _.lte
  12235. * @example
  12236. *
  12237. * _.gte(3, 1);
  12238. * // => true
  12239. *
  12240. * _.gte(3, 3);
  12241. * // => true
  12242. *
  12243. * _.gte(1, 3);
  12244. * // => false
  12245. */
  12246. var gte = createRelationalOperation(function(value, other) {
  12247. return value >= other;
  12248. });
  12249. /**
  12250. * Checks if `value` is likely an `arguments` object.
  12251. *
  12252. * @static
  12253. * @memberOf _
  12254. * @since 0.1.0
  12255. * @category Lang
  12256. * @param {*} value The value to check.
  12257. * @returns {boolean} Returns `true` if `value` is an `arguments` object,
  12258. * else `false`.
  12259. * @example
  12260. *
  12261. * _.isArguments(function() { return arguments; }());
  12262. * // => true
  12263. *
  12264. * _.isArguments([1, 2, 3]);
  12265. * // => false
  12266. */
  12267. var isArguments = baseIsArguments(function() { return arguments; }()) ? baseIsArguments : function(value) {
  12268. return isObjectLike(value) && hasOwnProperty.call(value, 'callee') &&
  12269. !propertyIsEnumerable.call(value, 'callee');
  12270. };
  12271. /**
  12272. * Checks if `value` is classified as an `Array` object.
  12273. *
  12274. * @static
  12275. * @memberOf _
  12276. * @since 0.1.0
  12277. * @category Lang
  12278. * @param {*} value The value to check.
  12279. * @returns {boolean} Returns `true` if `value` is an array, else `false`.
  12280. * @example
  12281. *
  12282. * _.isArray([1, 2, 3]);
  12283. * // => true
  12284. *
  12285. * _.isArray(document.body.children);
  12286. * // => false
  12287. *
  12288. * _.isArray('abc');
  12289. * // => false
  12290. *
  12291. * _.isArray(_.noop);
  12292. * // => false
  12293. */
  12294. var isArray = Array.isArray;
  12295. /**
  12296. * Checks if `value` is classified as an `ArrayBuffer` object.
  12297. *
  12298. * @static
  12299. * @memberOf _
  12300. * @since 4.3.0
  12301. * @category Lang
  12302. * @param {*} value The value to check.
  12303. * @returns {boolean} Returns `true` if `value` is an array buffer, else `false`.
  12304. * @example
  12305. *
  12306. * _.isArrayBuffer(new ArrayBuffer(2));
  12307. * // => true
  12308. *
  12309. * _.isArrayBuffer(new Array(2));
  12310. * // => false
  12311. */
  12312. var isArrayBuffer = nodeIsArrayBuffer ? baseUnary(nodeIsArrayBuffer) : baseIsArrayBuffer;
  12313. /**
  12314. * Checks if `value` is array-like. A value is considered array-like if it's
  12315. * not a function and has a `value.length` that's an integer greater than or
  12316. * equal to `0` and less than or equal to `Number.MAX_SAFE_INTEGER`.
  12317. *
  12318. * @static
  12319. * @memberOf _
  12320. * @since 4.0.0
  12321. * @category Lang
  12322. * @param {*} value The value to check.
  12323. * @returns {boolean} Returns `true` if `value` is array-like, else `false`.
  12324. * @example
  12325. *
  12326. * _.isArrayLike([1, 2, 3]);
  12327. * // => true
  12328. *
  12329. * _.isArrayLike(document.body.children);
  12330. * // => true
  12331. *
  12332. * _.isArrayLike('abc');
  12333. * // => true
  12334. *
  12335. * _.isArrayLike(_.noop);
  12336. * // => false
  12337. */
  12338. function isArrayLike(value) {
  12339. return value != null && isLength(value.length) && !isFunction(value);
  12340. }
  12341. /**
  12342. * This method is like `_.isArrayLike` except that it also checks if `value`
  12343. * is an object.
  12344. *
  12345. * @static
  12346. * @memberOf _
  12347. * @since 4.0.0
  12348. * @category Lang
  12349. * @param {*} value The value to check.
  12350. * @returns {boolean} Returns `true` if `value` is an array-like object,
  12351. * else `false`.
  12352. * @example
  12353. *
  12354. * _.isArrayLikeObject([1, 2, 3]);
  12355. * // => true
  12356. *
  12357. * _.isArrayLikeObject(document.body.children);
  12358. * // => true
  12359. *
  12360. * _.isArrayLikeObject('abc');
  12361. * // => false
  12362. *
  12363. * _.isArrayLikeObject(_.noop);
  12364. * // => false
  12365. */
  12366. function isArrayLikeObject(value) {
  12367. return isObjectLike(value) && isArrayLike(value);
  12368. }
  12369. /**
  12370. * Checks if `value` is classified as a boolean primitive or object.
  12371. *
  12372. * @static
  12373. * @memberOf _
  12374. * @since 0.1.0
  12375. * @category Lang
  12376. * @param {*} value The value to check.
  12377. * @returns {boolean} Returns `true` if `value` is a boolean, else `false`.
  12378. * @example
  12379. *
  12380. * _.isBoolean(false);
  12381. * // => true
  12382. *
  12383. * _.isBoolean(null);
  12384. * // => false
  12385. */
  12386. function isBoolean(value) {
  12387. return value === true || value === false ||
  12388. (isObjectLike(value) && baseGetTag(value) == boolTag);
  12389. }
  12390. /**
  12391. * Checks if `value` is a buffer.
  12392. *
  12393. * @static
  12394. * @memberOf _
  12395. * @since 4.3.0
  12396. * @category Lang
  12397. * @param {*} value The value to check.
  12398. * @returns {boolean} Returns `true` if `value` is a buffer, else `false`.
  12399. * @example
  12400. *
  12401. * _.isBuffer(new Buffer(2));
  12402. * // => true
  12403. *
  12404. * _.isBuffer(new Uint8Array(2));
  12405. * // => false
  12406. */
  12407. var isBuffer = nativeIsBuffer || stubFalse;
  12408. /**
  12409. * Checks if `value` is classified as a `Date` object.
  12410. *
  12411. * @static
  12412. * @memberOf _
  12413. * @since 0.1.0
  12414. * @category Lang
  12415. * @param {*} value The value to check.
  12416. * @returns {boolean} Returns `true` if `value` is a date object, else `false`.
  12417. * @example
  12418. *
  12419. * _.isDate(new Date);
  12420. * // => true
  12421. *
  12422. * _.isDate('Mon April 23 2012');
  12423. * // => false
  12424. */
  12425. var isDate = nodeIsDate ? baseUnary(nodeIsDate) : baseIsDate;
  12426. /**
  12427. * Checks if `value` is likely a DOM element.
  12428. *
  12429. * @static
  12430. * @memberOf _
  12431. * @since 0.1.0
  12432. * @category Lang
  12433. * @param {*} value The value to check.
  12434. * @returns {boolean} Returns `true` if `value` is a DOM element, else `false`.
  12435. * @example
  12436. *
  12437. * _.isElement(document.body);
  12438. * // => true
  12439. *
  12440. * _.isElement('<body>');
  12441. * // => false
  12442. */
  12443. function isElement(value) {
  12444. return isObjectLike(value) && value.nodeType === 1 && !isPlainObject(value);
  12445. }
  12446. /**
  12447. * Checks if `value` is an empty object, collection, map, or set.
  12448. *
  12449. * Objects are considered empty if they have no own enumerable string keyed
  12450. * properties.
  12451. *
  12452. * Array-like values such as `arguments` objects, arrays, buffers, strings, or
  12453. * jQuery-like collections are considered empty if they have a `length` of `0`.
  12454. * Similarly, maps and sets are considered empty if they have a `size` of `0`.
  12455. *
  12456. * @static
  12457. * @memberOf _
  12458. * @since 0.1.0
  12459. * @category Lang
  12460. * @param {*} value The value to check.
  12461. * @returns {boolean} Returns `true` if `value` is empty, else `false`.
  12462. * @example
  12463. *
  12464. * _.isEmpty(null);
  12465. * // => true
  12466. *
  12467. * _.isEmpty(true);
  12468. * // => true
  12469. *
  12470. * _.isEmpty(1);
  12471. * // => true
  12472. *
  12473. * _.isEmpty([1, 2, 3]);
  12474. * // => false
  12475. *
  12476. * _.isEmpty({ 'a': 1 });
  12477. * // => false
  12478. */
  12479. function isEmpty(value) {
  12480. if (value == null) {
  12481. return true;
  12482. }
  12483. if (isArrayLike(value) &&
  12484. (isArray(value) || typeof value == 'string' || typeof value.splice == 'function' ||
  12485. isBuffer(value) || isTypedArray(value) || isArguments(value))) {
  12486. return !value.length;
  12487. }
  12488. var tag = getTag(value);
  12489. if (tag == mapTag || tag == setTag) {
  12490. return !value.size;
  12491. }
  12492. if (isPrototype(value)) {
  12493. return !baseKeys(value).length;
  12494. }
  12495. for (var key in value) {
  12496. if (hasOwnProperty.call(value, key)) {
  12497. return false;
  12498. }
  12499. }
  12500. return true;
  12501. }
  12502. /**
  12503. * Performs a deep comparison between two values to determine if they are
  12504. * equivalent.
  12505. *
  12506. * **Note:** This method supports comparing arrays, array buffers, booleans,
  12507. * date objects, error objects, maps, numbers, `Object` objects, regexes,
  12508. * sets, strings, symbols, and typed arrays. `Object` objects are compared
  12509. * by their own, not inherited, enumerable properties. Functions and DOM
  12510. * nodes are compared by strict equality, i.e. `===`.
  12511. *
  12512. * @static
  12513. * @memberOf _
  12514. * @since 0.1.0
  12515. * @category Lang
  12516. * @param {*} value The value to compare.
  12517. * @param {*} other The other value to compare.
  12518. * @returns {boolean} Returns `true` if the values are equivalent, else `false`.
  12519. * @example
  12520. *
  12521. * var object = { 'a': 1 };
  12522. * var other = { 'a': 1 };
  12523. *
  12524. * _.isEqual(object, other);
  12525. * // => true
  12526. *
  12527. * object === other;
  12528. * // => false
  12529. */
  12530. function isEqual(value, other) {
  12531. return baseIsEqual(value, other);
  12532. }
  12533. /**
  12534. * This method is like `_.isEqual` except that it accepts `customizer` which
  12535. * is invoked to compare values. If `customizer` returns `undefined`, comparisons
  12536. * are handled by the method instead. The `customizer` is invoked with up to
  12537. * six arguments: (objValue, othValue [, index|key, object, other, stack]).
  12538. *
  12539. * @static
  12540. * @memberOf _
  12541. * @since 4.0.0
  12542. * @category Lang
  12543. * @param {*} value The value to compare.
  12544. * @param {*} other The other value to compare.
  12545. * @param {Function} [customizer] The function to customize comparisons.
  12546. * @returns {boolean} Returns `true` if the values are equivalent, else `false`.
  12547. * @example
  12548. *
  12549. * function isGreeting(value) {
  12550. * return /^h(?:i|ello)$/.test(value);
  12551. * }
  12552. *
  12553. * function customizer(objValue, othValue) {
  12554. * if (isGreeting(objValue) && isGreeting(othValue)) {
  12555. * return true;
  12556. * }
  12557. * }
  12558. *
  12559. * var array = ['hello', 'goodbye'];
  12560. * var other = ['hi', 'goodbye'];
  12561. *
  12562. * _.isEqualWith(array, other, customizer);
  12563. * // => true
  12564. */
  12565. function isEqualWith(value, other, customizer) {
  12566. customizer = typeof customizer == 'function' ? customizer : undefined;
  12567. var result = customizer ? customizer(value, other) : undefined;
  12568. return result === undefined ? baseIsEqual(value, other, undefined, customizer) : !!result;
  12569. }
  12570. /**
  12571. * Checks if `value` is an `Error`, `EvalError`, `RangeError`, `ReferenceError`,
  12572. * `SyntaxError`, `TypeError`, or `URIError` object.
  12573. *
  12574. * @static
  12575. * @memberOf _
  12576. * @since 3.0.0
  12577. * @category Lang
  12578. * @param {*} value The value to check.
  12579. * @returns {boolean} Returns `true` if `value` is an error object, else `false`.
  12580. * @example
  12581. *
  12582. * _.isError(new Error);
  12583. * // => true
  12584. *
  12585. * _.isError(Error);
  12586. * // => false
  12587. */
  12588. function isError(value) {
  12589. if (!isObjectLike(value)) {
  12590. return false;
  12591. }
  12592. var tag = baseGetTag(value);
  12593. return tag == errorTag || tag == domExcTag ||
  12594. (typeof value.message == 'string' && typeof value.name == 'string' && !isPlainObject(value));
  12595. }
  12596. /**
  12597. * Checks if `value` is a finite primitive number.
  12598. *
  12599. * **Note:** This method is based on
  12600. * [`Number.isFinite`](https://mdn.io/Number/isFinite).
  12601. *
  12602. * @static
  12603. * @memberOf _
  12604. * @since 0.1.0
  12605. * @category Lang
  12606. * @param {*} value The value to check.
  12607. * @returns {boolean} Returns `true` if `value` is a finite number, else `false`.
  12608. * @example
  12609. *
  12610. * _.isFinite(3);
  12611. * // => true
  12612. *
  12613. * _.isFinite(Number.MIN_VALUE);
  12614. * // => true
  12615. *
  12616. * _.isFinite(Infinity);
  12617. * // => false
  12618. *
  12619. * _.isFinite('3');
  12620. * // => false
  12621. */
  12622. function isFinite(value) {
  12623. return typeof value == 'number' && nativeIsFinite(value);
  12624. }
  12625. /**
  12626. * Checks if `value` is classified as a `Function` object.
  12627. *
  12628. * @static
  12629. * @memberOf _
  12630. * @since 0.1.0
  12631. * @category Lang
  12632. * @param {*} value The value to check.
  12633. * @returns {boolean} Returns `true` if `value` is a function, else `false`.
  12634. * @example
  12635. *
  12636. * _.isFunction(_);
  12637. * // => true
  12638. *
  12639. * _.isFunction(/abc/);
  12640. * // => false
  12641. */
  12642. function isFunction(value) {
  12643. if (!isObject(value)) {
  12644. return false;
  12645. }
  12646. // The use of `Object#toString` avoids issues with the `typeof` operator
  12647. // in Safari 9 which returns 'object' for typed arrays and other constructors.
  12648. var tag = baseGetTag(value);
  12649. return tag == funcTag || tag == genTag || tag == asyncTag || tag == proxyTag;
  12650. }
  12651. /**
  12652. * Checks if `value` is an integer.
  12653. *
  12654. * **Note:** This method is based on
  12655. * [`Number.isInteger`](https://mdn.io/Number/isInteger).
  12656. *
  12657. * @static
  12658. * @memberOf _
  12659. * @since 4.0.0
  12660. * @category Lang
  12661. * @param {*} value The value to check.
  12662. * @returns {boolean} Returns `true` if `value` is an integer, else `false`.
  12663. * @example
  12664. *
  12665. * _.isInteger(3);
  12666. * // => true
  12667. *
  12668. * _.isInteger(Number.MIN_VALUE);
  12669. * // => false
  12670. *
  12671. * _.isInteger(Infinity);
  12672. * // => false
  12673. *
  12674. * _.isInteger('3');
  12675. * // => false
  12676. */
  12677. function isInteger(value) {
  12678. return typeof value == 'number' && value == toInteger(value);
  12679. }
  12680. /**
  12681. * Checks if `value` is a valid array-like length.
  12682. *
  12683. * **Note:** This method is loosely based on
  12684. * [`ToLength`](http://ecma-international.org/ecma-262/7.0/#sec-tolength).
  12685. *
  12686. * @static
  12687. * @memberOf _
  12688. * @since 4.0.0
  12689. * @category Lang
  12690. * @param {*} value The value to check.
  12691. * @returns {boolean} Returns `true` if `value` is a valid length, else `false`.
  12692. * @example
  12693. *
  12694. * _.isLength(3);
  12695. * // => true
  12696. *
  12697. * _.isLength(Number.MIN_VALUE);
  12698. * // => false
  12699. *
  12700. * _.isLength(Infinity);
  12701. * // => false
  12702. *
  12703. * _.isLength('3');
  12704. * // => false
  12705. */
  12706. function isLength(value) {
  12707. return typeof value == 'number' &&
  12708. value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER;
  12709. }
  12710. /**
  12711. * Checks if `value` is the
  12712. * [language type](http://www.ecma-international.org/ecma-262/7.0/#sec-ecmascript-language-types)
  12713. * of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)
  12714. *
  12715. * @static
  12716. * @memberOf _
  12717. * @since 0.1.0
  12718. * @category Lang
  12719. * @param {*} value The value to check.
  12720. * @returns {boolean} Returns `true` if `value` is an object, else `false`.
  12721. * @example
  12722. *
  12723. * _.isObject({});
  12724. * // => true
  12725. *
  12726. * _.isObject([1, 2, 3]);
  12727. * // => true
  12728. *
  12729. * _.isObject(_.noop);
  12730. * // => true
  12731. *
  12732. * _.isObject(null);
  12733. * // => false
  12734. */
  12735. function isObject(value) {
  12736. var type = typeof value;
  12737. return value != null && (type == 'object' || type == 'function');
  12738. }
  12739. /**
  12740. * Checks if `value` is object-like. A value is object-like if it's not `null`
  12741. * and has a `typeof` result of "object".
  12742. *
  12743. * @static
  12744. * @memberOf _
  12745. * @since 4.0.0
  12746. * @category Lang
  12747. * @param {*} value The value to check.
  12748. * @returns {boolean} Returns `true` if `value` is object-like, else `false`.
  12749. * @example
  12750. *
  12751. * _.isObjectLike({});
  12752. * // => true
  12753. *
  12754. * _.isObjectLike([1, 2, 3]);
  12755. * // => true
  12756. *
  12757. * _.isObjectLike(_.noop);
  12758. * // => false
  12759. *
  12760. * _.isObjectLike(null);
  12761. * // => false
  12762. */
  12763. function isObjectLike(value) {
  12764. return value != null && typeof value == 'object';
  12765. }
  12766. /**
  12767. * Checks if `value` is classified as a `Map` object.
  12768. *
  12769. * @static
  12770. * @memberOf _
  12771. * @since 4.3.0
  12772. * @category Lang
  12773. * @param {*} value The value to check.
  12774. * @returns {boolean} Returns `true` if `value` is a map, else `false`.
  12775. * @example
  12776. *
  12777. * _.isMap(new Map);
  12778. * // => true
  12779. *
  12780. * _.isMap(new WeakMap);
  12781. * // => false
  12782. */
  12783. var isMap = nodeIsMap ? baseUnary(nodeIsMap) : baseIsMap;
  12784. /**
  12785. * Performs a partial deep comparison between `object` and `source` to
  12786. * determine if `object` contains equivalent property values.
  12787. *
  12788. * **Note:** This method is equivalent to `_.matches` when `source` is
  12789. * partially applied.
  12790. *
  12791. * Partial comparisons will match empty array and empty object `source`
  12792. * values against any array or object value, respectively. See `_.isEqual`
  12793. * for a list of supported value comparisons.
  12794. *
  12795. * @static
  12796. * @memberOf _
  12797. * @since 3.0.0
  12798. * @category Lang
  12799. * @param {Object} object The object to inspect.
  12800. * @param {Object} source The object of property values to match.
  12801. * @returns {boolean} Returns `true` if `object` is a match, else `false`.
  12802. * @example
  12803. *
  12804. * var object = { 'a': 1, 'b': 2 };
  12805. *
  12806. * _.isMatch(object, { 'b': 2 });
  12807. * // => true
  12808. *
  12809. * _.isMatch(object, { 'b': 1 });
  12810. * // => false
  12811. */
  12812. function isMatch(object, source) {
  12813. return object === source || baseIsMatch(object, source, getMatchData(source));
  12814. }
  12815. /**
  12816. * This method is like `_.isMatch` except that it accepts `customizer` which
  12817. * is invoked to compare values. If `customizer` returns `undefined`, comparisons
  12818. * are handled by the method instead. The `customizer` is invoked with five
  12819. * arguments: (objValue, srcValue, index|key, object, source).
  12820. *
  12821. * @static
  12822. * @memberOf _
  12823. * @since 4.0.0
  12824. * @category Lang
  12825. * @param {Object} object The object to inspect.
  12826. * @param {Object} source The object of property values to match.
  12827. * @param {Function} [customizer] The function to customize comparisons.
  12828. * @returns {boolean} Returns `true` if `object` is a match, else `false`.
  12829. * @example
  12830. *
  12831. * function isGreeting(value) {
  12832. * return /^h(?:i|ello)$/.test(value);
  12833. * }
  12834. *
  12835. * function customizer(objValue, srcValue) {
  12836. * if (isGreeting(objValue) && isGreeting(srcValue)) {
  12837. * return true;
  12838. * }
  12839. * }
  12840. *
  12841. * var object = { 'greeting': 'hello' };
  12842. * var source = { 'greeting': 'hi' };
  12843. *
  12844. * _.isMatchWith(object, source, customizer);
  12845. * // => true
  12846. */
  12847. function isMatchWith(object, source, customizer) {
  12848. customizer = typeof customizer == 'function' ? customizer : undefined;
  12849. return baseIsMatch(object, source, getMatchData(source), customizer);
  12850. }
  12851. /**
  12852. * Checks if `value` is `NaN`.
  12853. *
  12854. * **Note:** This method is based on
  12855. * [`Number.isNaN`](https://mdn.io/Number/isNaN) and is not the same as
  12856. * global [`isNaN`](https://mdn.io/isNaN) which returns `true` for
  12857. * `undefined` and other non-number values.
  12858. *
  12859. * @static
  12860. * @memberOf _
  12861. * @since 0.1.0
  12862. * @category Lang
  12863. * @param {*} value The value to check.
  12864. * @returns {boolean} Returns `true` if `value` is `NaN`, else `false`.
  12865. * @example
  12866. *
  12867. * _.isNaN(NaN);
  12868. * // => true
  12869. *
  12870. * _.isNaN(new Number(NaN));
  12871. * // => true
  12872. *
  12873. * isNaN(undefined);
  12874. * // => true
  12875. *
  12876. * _.isNaN(undefined);
  12877. * // => false
  12878. */
  12879. function isNaN(value) {
  12880. // An `NaN` primitive is the only value that is not equal to itself.
  12881. // Perform the `toStringTag` check first to avoid errors with some
  12882. // ActiveX objects in IE.
  12883. return isNumber(value) && value != +value;
  12884. }
  12885. /**
  12886. * Checks if `value` is a pristine native function.
  12887. *
  12888. * **Note:** This method can't reliably detect native functions in the presence
  12889. * of the core-js package because core-js circumvents this kind of detection.
  12890. * Despite multiple requests, the core-js maintainer has made it clear: any
  12891. * attempt to fix the detection will be obstructed. As a result, we're left
  12892. * with little choice but to throw an error. Unfortunately, this also affects
  12893. * packages, like [babel-polyfill](https://www.npmjs.com/package/babel-polyfill),
  12894. * which rely on core-js.
  12895. *
  12896. * @static
  12897. * @memberOf _
  12898. * @since 3.0.0
  12899. * @category Lang
  12900. * @param {*} value The value to check.
  12901. * @returns {boolean} Returns `true` if `value` is a native function,
  12902. * else `false`.
  12903. * @example
  12904. *
  12905. * _.isNative(Array.prototype.push);
  12906. * // => true
  12907. *
  12908. * _.isNative(_);
  12909. * // => false
  12910. */
  12911. function isNative(value) {
  12912. if (isMaskable(value)) {
  12913. throw new Error(CORE_ERROR_TEXT);
  12914. }
  12915. return baseIsNative(value);
  12916. }
  12917. /**
  12918. * Checks if `value` is `null`.
  12919. *
  12920. * @static
  12921. * @memberOf _
  12922. * @since 0.1.0
  12923. * @category Lang
  12924. * @param {*} value The value to check.
  12925. * @returns {boolean} Returns `true` if `value` is `null`, else `false`.
  12926. * @example
  12927. *
  12928. * _.isNull(null);
  12929. * // => true
  12930. *
  12931. * _.isNull(void 0);
  12932. * // => false
  12933. */
  12934. function isNull(value) {
  12935. return value === null;
  12936. }
  12937. /**
  12938. * Checks if `value` is `null` or `undefined`.
  12939. *
  12940. * @static
  12941. * @memberOf _
  12942. * @since 4.0.0
  12943. * @category Lang
  12944. * @param {*} value The value to check.
  12945. * @returns {boolean} Returns `true` if `value` is nullish, else `false`.
  12946. * @example
  12947. *
  12948. * _.isNil(null);
  12949. * // => true
  12950. *
  12951. * _.isNil(void 0);
  12952. * // => true
  12953. *
  12954. * _.isNil(NaN);
  12955. * // => false
  12956. */
  12957. function isNil(value) {
  12958. return value == null;
  12959. }
  12960. /**
  12961. * Checks if `value` is classified as a `Number` primitive or object.
  12962. *
  12963. * **Note:** To exclude `Infinity`, `-Infinity`, and `NaN`, which are
  12964. * classified as numbers, use the `_.isFinite` method.
  12965. *
  12966. * @static
  12967. * @memberOf _
  12968. * @since 0.1.0
  12969. * @category Lang
  12970. * @param {*} value The value to check.
  12971. * @returns {boolean} Returns `true` if `value` is a number, else `false`.
  12972. * @example
  12973. *
  12974. * _.isNumber(3);
  12975. * // => true
  12976. *
  12977. * _.isNumber(Number.MIN_VALUE);
  12978. * // => true
  12979. *
  12980. * _.isNumber(Infinity);
  12981. * // => true
  12982. *
  12983. * _.isNumber('3');
  12984. * // => false
  12985. */
  12986. function isNumber(value) {
  12987. return typeof value == 'number' ||
  12988. (isObjectLike(value) && baseGetTag(value) == numberTag);
  12989. }
  12990. /**
  12991. * Checks if `value` is a plain object, that is, an object created by the
  12992. * `Object` constructor or one with a `[[Prototype]]` of `null`.
  12993. *
  12994. * @static
  12995. * @memberOf _
  12996. * @since 0.8.0
  12997. * @category Lang
  12998. * @param {*} value The value to check.
  12999. * @returns {boolean} Returns `true` if `value` is a plain object, else `false`.
  13000. * @example
  13001. *
  13002. * function Foo() {
  13003. * this.a = 1;
  13004. * }
  13005. *
  13006. * _.isPlainObject(new Foo);
  13007. * // => false
  13008. *
  13009. * _.isPlainObject([1, 2, 3]);
  13010. * // => false
  13011. *
  13012. * _.isPlainObject({ 'x': 0, 'y': 0 });
  13013. * // => true
  13014. *
  13015. * _.isPlainObject(Object.create(null));
  13016. * // => true
  13017. */
  13018. function isPlainObject(value) {
  13019. if (!isObjectLike(value) || baseGetTag(value) != objectTag) {
  13020. return false;
  13021. }
  13022. var proto = getPrototype(value);
  13023. if (proto === null) {
  13024. return true;
  13025. }
  13026. var Ctor = hasOwnProperty.call(proto, 'constructor') && proto.constructor;
  13027. return typeof Ctor == 'function' && Ctor instanceof Ctor &&
  13028. funcToString.call(Ctor) == objectCtorString;
  13029. }
  13030. /**
  13031. * Checks if `value` is classified as a `RegExp` object.
  13032. *
  13033. * @static
  13034. * @memberOf _
  13035. * @since 0.1.0
  13036. * @category Lang
  13037. * @param {*} value The value to check.
  13038. * @returns {boolean} Returns `true` if `value` is a regexp, else `false`.
  13039. * @example
  13040. *
  13041. * _.isRegExp(/abc/);
  13042. * // => true
  13043. *
  13044. * _.isRegExp('/abc/');
  13045. * // => false
  13046. */
  13047. var isRegExp = nodeIsRegExp ? baseUnary(nodeIsRegExp) : baseIsRegExp;
  13048. /**
  13049. * Checks if `value` is a safe integer. An integer is safe if it's an IEEE-754
  13050. * double precision number which isn't the result of a rounded unsafe integer.
  13051. *
  13052. * **Note:** This method is based on
  13053. * [`Number.isSafeInteger`](https://mdn.io/Number/isSafeInteger).
  13054. *
  13055. * @static
  13056. * @memberOf _
  13057. * @since 4.0.0
  13058. * @category Lang
  13059. * @param {*} value The value to check.
  13060. * @returns {boolean} Returns `true` if `value` is a safe integer, else `false`.
  13061. * @example
  13062. *
  13063. * _.isSafeInteger(3);
  13064. * // => true
  13065. *
  13066. * _.isSafeInteger(Number.MIN_VALUE);
  13067. * // => false
  13068. *
  13069. * _.isSafeInteger(Infinity);
  13070. * // => false
  13071. *
  13072. * _.isSafeInteger('3');
  13073. * // => false
  13074. */
  13075. function isSafeInteger(value) {
  13076. return isInteger(value) && value >= -MAX_SAFE_INTEGER && value <= MAX_SAFE_INTEGER;
  13077. }
  13078. /**
  13079. * Checks if `value` is classified as a `Set` object.
  13080. *
  13081. * @static
  13082. * @memberOf _
  13083. * @since 4.3.0
  13084. * @category Lang
  13085. * @param {*} value The value to check.
  13086. * @returns {boolean} Returns `true` if `value` is a set, else `false`.
  13087. * @example
  13088. *
  13089. * _.isSet(new Set);
  13090. * // => true
  13091. *
  13092. * _.isSet(new WeakSet);
  13093. * // => false
  13094. */
  13095. var isSet = nodeIsSet ? baseUnary(nodeIsSet) : baseIsSet;
  13096. /**
  13097. * Checks if `value` is classified as a `String` primitive or object.
  13098. *
  13099. * @static
  13100. * @since 0.1.0
  13101. * @memberOf _
  13102. * @category Lang
  13103. * @param {*} value The value to check.
  13104. * @returns {boolean} Returns `true` if `value` is a string, else `false`.
  13105. * @example
  13106. *
  13107. * _.isString('abc');
  13108. * // => true
  13109. *
  13110. * _.isString(1);
  13111. * // => false
  13112. */
  13113. function isString(value) {
  13114. return typeof value == 'string' ||
  13115. (!isArray(value) && isObjectLike(value) && baseGetTag(value) == stringTag);
  13116. }
  13117. /**
  13118. * Checks if `value` is classified as a `Symbol` primitive or object.
  13119. *
  13120. * @static
  13121. * @memberOf _
  13122. * @since 4.0.0
  13123. * @category Lang
  13124. * @param {*} value The value to check.
  13125. * @returns {boolean} Returns `true` if `value` is a symbol, else `false`.
  13126. * @example
  13127. *
  13128. * _.isSymbol(Symbol.iterator);
  13129. * // => true
  13130. *
  13131. * _.isSymbol('abc');
  13132. * // => false
  13133. */
  13134. function isSymbol(value) {
  13135. return typeof value == 'symbol' ||
  13136. (isObjectLike(value) && baseGetTag(value) == symbolTag);
  13137. }
  13138. /**
  13139. * Checks if `value` is classified as a typed array.
  13140. *
  13141. * @static
  13142. * @memberOf _
  13143. * @since 3.0.0
  13144. * @category Lang
  13145. * @param {*} value The value to check.
  13146. * @returns {boolean} Returns `true` if `value` is a typed array, else `false`.
  13147. * @example
  13148. *
  13149. * _.isTypedArray(new Uint8Array);
  13150. * // => true
  13151. *
  13152. * _.isTypedArray([]);
  13153. * // => false
  13154. */
  13155. var isTypedArray = nodeIsTypedArray ? baseUnary(nodeIsTypedArray) : baseIsTypedArray;
  13156. /**
  13157. * Checks if `value` is `undefined`.
  13158. *
  13159. * @static
  13160. * @since 0.1.0
  13161. * @memberOf _
  13162. * @category Lang
  13163. * @param {*} value The value to check.
  13164. * @returns {boolean} Returns `true` if `value` is `undefined`, else `false`.
  13165. * @example
  13166. *
  13167. * _.isUndefined(void 0);
  13168. * // => true
  13169. *
  13170. * _.isUndefined(null);
  13171. * // => false
  13172. */
  13173. function isUndefined(value) {
  13174. return value === undefined;
  13175. }
  13176. /**
  13177. * Checks if `value` is classified as a `WeakMap` object.
  13178. *
  13179. * @static
  13180. * @memberOf _
  13181. * @since 4.3.0
  13182. * @category Lang
  13183. * @param {*} value The value to check.
  13184. * @returns {boolean} Returns `true` if `value` is a weak map, else `false`.
  13185. * @example
  13186. *
  13187. * _.isWeakMap(new WeakMap);
  13188. * // => true
  13189. *
  13190. * _.isWeakMap(new Map);
  13191. * // => false
  13192. */
  13193. function isWeakMap(value) {
  13194. return isObjectLike(value) && getTag(value) == weakMapTag;
  13195. }
  13196. /**
  13197. * Checks if `value` is classified as a `WeakSet` object.
  13198. *
  13199. * @static
  13200. * @memberOf _
  13201. * @since 4.3.0
  13202. * @category Lang
  13203. * @param {*} value The value to check.
  13204. * @returns {boolean} Returns `true` if `value` is a weak set, else `false`.
  13205. * @example
  13206. *
  13207. * _.isWeakSet(new WeakSet);
  13208. * // => true
  13209. *
  13210. * _.isWeakSet(new Set);
  13211. * // => false
  13212. */
  13213. function isWeakSet(value) {
  13214. return isObjectLike(value) && baseGetTag(value) == weakSetTag;
  13215. }
  13216. /**
  13217. * Checks if `value` is less than `other`.
  13218. *
  13219. * @static
  13220. * @memberOf _
  13221. * @since 3.9.0
  13222. * @category Lang
  13223. * @param {*} value The value to compare.
  13224. * @param {*} other The other value to compare.
  13225. * @returns {boolean} Returns `true` if `value` is less than `other`,
  13226. * else `false`.
  13227. * @see _.gt
  13228. * @example
  13229. *
  13230. * _.lt(1, 3);
  13231. * // => true
  13232. *
  13233. * _.lt(3, 3);
  13234. * // => false
  13235. *
  13236. * _.lt(3, 1);
  13237. * // => false
  13238. */
  13239. var lt = createRelationalOperation(baseLt);
  13240. /**
  13241. * Checks if `value` is less than or equal to `other`.
  13242. *
  13243. * @static
  13244. * @memberOf _
  13245. * @since 3.9.0
  13246. * @category Lang
  13247. * @param {*} value The value to compare.
  13248. * @param {*} other The other value to compare.
  13249. * @returns {boolean} Returns `true` if `value` is less than or equal to
  13250. * `other`, else `false`.
  13251. * @see _.gte
  13252. * @example
  13253. *
  13254. * _.lte(1, 3);
  13255. * // => true
  13256. *
  13257. * _.lte(3, 3);
  13258. * // => true
  13259. *
  13260. * _.lte(3, 1);
  13261. * // => false
  13262. */
  13263. var lte = createRelationalOperation(function(value, other) {
  13264. return value <= other;
  13265. });
  13266. /**
  13267. * Converts `value` to an array.
  13268. *
  13269. * @static
  13270. * @since 0.1.0
  13271. * @memberOf _
  13272. * @category Lang
  13273. * @param {*} value The value to convert.
  13274. * @returns {Array} Returns the converted array.
  13275. * @example
  13276. *
  13277. * _.toArray({ 'a': 1, 'b': 2 });
  13278. * // => [1, 2]
  13279. *
  13280. * _.toArray('abc');
  13281. * // => ['a', 'b', 'c']
  13282. *
  13283. * _.toArray(1);
  13284. * // => []
  13285. *
  13286. * _.toArray(null);
  13287. * // => []
  13288. */
  13289. function toArray(value) {
  13290. if (!value) {
  13291. return [];
  13292. }
  13293. if (isArrayLike(value)) {
  13294. return isString(value) ? stringToArray(value) : copyArray(value);
  13295. }
  13296. if (symIterator && value[symIterator]) {
  13297. return iteratorToArray(value[symIterator]());
  13298. }
  13299. var tag = getTag(value),
  13300. func = tag == mapTag ? mapToArray : (tag == setTag ? setToArray : values);
  13301. return func(value);
  13302. }
  13303. /**
  13304. * Converts `value` to a finite number.
  13305. *
  13306. * @static
  13307. * @memberOf _
  13308. * @since 4.12.0
  13309. * @category Lang
  13310. * @param {*} value The value to convert.
  13311. * @returns {number} Returns the converted number.
  13312. * @example
  13313. *
  13314. * _.toFinite(3.2);
  13315. * // => 3.2
  13316. *
  13317. * _.toFinite(Number.MIN_VALUE);
  13318. * // => 5e-324
  13319. *
  13320. * _.toFinite(Infinity);
  13321. * // => 1.7976931348623157e+308
  13322. *
  13323. * _.toFinite('3.2');
  13324. * // => 3.2
  13325. */
  13326. function toFinite(value) {
  13327. if (!value) {
  13328. return value === 0 ? value : 0;
  13329. }
  13330. value = toNumber(value);
  13331. if (value === INFINITY || value === -INFINITY) {
  13332. var sign = (value < 0 ? -1 : 1);
  13333. return sign * MAX_INTEGER;
  13334. }
  13335. return value === value ? value : 0;
  13336. }
  13337. /**
  13338. * Converts `value` to an integer.
  13339. *
  13340. * **Note:** This method is loosely based on
  13341. * [`ToInteger`](http://www.ecma-international.org/ecma-262/7.0/#sec-tointeger).
  13342. *
  13343. * @static
  13344. * @memberOf _
  13345. * @since 4.0.0
  13346. * @category Lang
  13347. * @param {*} value The value to convert.
  13348. * @returns {number} Returns the converted integer.
  13349. * @example
  13350. *
  13351. * _.toInteger(3.2);
  13352. * // => 3
  13353. *
  13354. * _.toInteger(Number.MIN_VALUE);
  13355. * // => 0
  13356. *
  13357. * _.toInteger(Infinity);
  13358. * // => 1.7976931348623157e+308
  13359. *
  13360. * _.toInteger('3.2');
  13361. * // => 3
  13362. */
  13363. function toInteger(value) {
  13364. var result = toFinite(value),
  13365. remainder = result % 1;
  13366. return result === result ? (remainder ? result - remainder : result) : 0;
  13367. }
  13368. /**
  13369. * Converts `value` to an integer suitable for use as the length of an
  13370. * array-like object.
  13371. *
  13372. * **Note:** This method is based on
  13373. * [`ToLength`](http://ecma-international.org/ecma-262/7.0/#sec-tolength).
  13374. *
  13375. * @static
  13376. * @memberOf _
  13377. * @since 4.0.0
  13378. * @category Lang
  13379. * @param {*} value The value to convert.
  13380. * @returns {number} Returns the converted integer.
  13381. * @example
  13382. *
  13383. * _.toLength(3.2);
  13384. * // => 3
  13385. *
  13386. * _.toLength(Number.MIN_VALUE);
  13387. * // => 0
  13388. *
  13389. * _.toLength(Infinity);
  13390. * // => 4294967295
  13391. *
  13392. * _.toLength('3.2');
  13393. * // => 3
  13394. */
  13395. function toLength(value) {
  13396. return value ? baseClamp(toInteger(value), 0, MAX_ARRAY_LENGTH) : 0;
  13397. }
  13398. /**
  13399. * Converts `value` to a number.
  13400. *
  13401. * @static
  13402. * @memberOf _
  13403. * @since 4.0.0
  13404. * @category Lang
  13405. * @param {*} value The value to process.
  13406. * @returns {number} Returns the number.
  13407. * @example
  13408. *
  13409. * _.toNumber(3.2);
  13410. * // => 3.2
  13411. *
  13412. * _.toNumber(Number.MIN_VALUE);
  13413. * // => 5e-324
  13414. *
  13415. * _.toNumber(Infinity);
  13416. * // => Infinity
  13417. *
  13418. * _.toNumber('3.2');
  13419. * // => 3.2
  13420. */
  13421. function toNumber(value) {
  13422. if (typeof value == 'number') {
  13423. return value;
  13424. }
  13425. if (isSymbol(value)) {
  13426. return NAN;
  13427. }
  13428. if (isObject(value)) {
  13429. var other = typeof value.valueOf == 'function' ? value.valueOf() : value;
  13430. value = isObject(other) ? (other + '') : other;
  13431. }
  13432. if (typeof value != 'string') {
  13433. return value === 0 ? value : +value;
  13434. }
  13435. value = baseTrim(value);
  13436. var isBinary = reIsBinary.test(value);
  13437. return (isBinary || reIsOctal.test(value))
  13438. ? freeParseInt(value.slice(2), isBinary ? 2 : 8)
  13439. : (reIsBadHex.test(value) ? NAN : +value);
  13440. }
  13441. /**
  13442. * Converts `value` to a plain object flattening inherited enumerable string
  13443. * keyed properties of `value` to own properties of the plain object.
  13444. *
  13445. * @static
  13446. * @memberOf _
  13447. * @since 3.0.0
  13448. * @category Lang
  13449. * @param {*} value The value to convert.
  13450. * @returns {Object} Returns the converted plain object.
  13451. * @example
  13452. *
  13453. * function Foo() {
  13454. * this.b = 2;
  13455. * }
  13456. *
  13457. * Foo.prototype.c = 3;
  13458. *
  13459. * _.assign({ 'a': 1 }, new Foo);
  13460. * // => { 'a': 1, 'b': 2 }
  13461. *
  13462. * _.assign({ 'a': 1 }, _.toPlainObject(new Foo));
  13463. * // => { 'a': 1, 'b': 2, 'c': 3 }
  13464. */
  13465. function toPlainObject(value) {
  13466. return copyObject(value, keysIn(value));
  13467. }
  13468. /**
  13469. * Converts `value` to a safe integer. A safe integer can be compared and
  13470. * represented correctly.
  13471. *
  13472. * @static
  13473. * @memberOf _
  13474. * @since 4.0.0
  13475. * @category Lang
  13476. * @param {*} value The value to convert.
  13477. * @returns {number} Returns the converted integer.
  13478. * @example
  13479. *
  13480. * _.toSafeInteger(3.2);
  13481. * // => 3
  13482. *
  13483. * _.toSafeInteger(Number.MIN_VALUE);
  13484. * // => 0
  13485. *
  13486. * _.toSafeInteger(Infinity);
  13487. * // => 9007199254740991
  13488. *
  13489. * _.toSafeInteger('3.2');
  13490. * // => 3
  13491. */
  13492. function toSafeInteger(value) {
  13493. return value
  13494. ? baseClamp(toInteger(value), -MAX_SAFE_INTEGER, MAX_SAFE_INTEGER)
  13495. : (value === 0 ? value : 0);
  13496. }
  13497. /**
  13498. * Converts `value` to a string. An empty string is returned for `null`
  13499. * and `undefined` values. The sign of `-0` is preserved.
  13500. *
  13501. * @static
  13502. * @memberOf _
  13503. * @since 4.0.0
  13504. * @category Lang
  13505. * @param {*} value The value to convert.
  13506. * @returns {string} Returns the converted string.
  13507. * @example
  13508. *
  13509. * _.toString(null);
  13510. * // => ''
  13511. *
  13512. * _.toString(-0);
  13513. * // => '-0'
  13514. *
  13515. * _.toString([1, 2, 3]);
  13516. * // => '1,2,3'
  13517. */
  13518. function toString(value) {
  13519. return value == null ? '' : baseToString(value);
  13520. }
  13521. /*------------------------------------------------------------------------*/
  13522. /**
  13523. * Assigns own enumerable string keyed properties of source objects to the
  13524. * destination object. Source objects are applied from left to right.
  13525. * Subsequent sources overwrite property assignments of previous sources.
  13526. *
  13527. * **Note:** This method mutates `object` and is loosely based on
  13528. * [`Object.assign`](https://mdn.io/Object/assign).
  13529. *
  13530. * @static
  13531. * @memberOf _
  13532. * @since 0.10.0
  13533. * @category Object
  13534. * @param {Object} object The destination object.
  13535. * @param {...Object} [sources] The source objects.
  13536. * @returns {Object} Returns `object`.
  13537. * @see _.assignIn
  13538. * @example
  13539. *
  13540. * function Foo() {
  13541. * this.a = 1;
  13542. * }
  13543. *
  13544. * function Bar() {
  13545. * this.c = 3;
  13546. * }
  13547. *
  13548. * Foo.prototype.b = 2;
  13549. * Bar.prototype.d = 4;
  13550. *
  13551. * _.assign({ 'a': 0 }, new Foo, new Bar);
  13552. * // => { 'a': 1, 'c': 3 }
  13553. */
  13554. var assign = createAssigner(function(object, source) {
  13555. if (isPrototype(source) || isArrayLike(source)) {
  13556. copyObject(source, keys(source), object);
  13557. return;
  13558. }
  13559. for (var key in source) {
  13560. if (hasOwnProperty.call(source, key)) {
  13561. assignValue(object, key, source[key]);
  13562. }
  13563. }
  13564. });
  13565. /**
  13566. * This method is like `_.assign` except that it iterates over own and
  13567. * inherited source properties.
  13568. *
  13569. * **Note:** This method mutates `object`.
  13570. *
  13571. * @static
  13572. * @memberOf _
  13573. * @since 4.0.0
  13574. * @alias extend
  13575. * @category Object
  13576. * @param {Object} object The destination object.
  13577. * @param {...Object} [sources] The source objects.
  13578. * @returns {Object} Returns `object`.
  13579. * @see _.assign
  13580. * @example
  13581. *
  13582. * function Foo() {
  13583. * this.a = 1;
  13584. * }
  13585. *
  13586. * function Bar() {
  13587. * this.c = 3;
  13588. * }
  13589. *
  13590. * Foo.prototype.b = 2;
  13591. * Bar.prototype.d = 4;
  13592. *
  13593. * _.assignIn({ 'a': 0 }, new Foo, new Bar);
  13594. * // => { 'a': 1, 'b': 2, 'c': 3, 'd': 4 }
  13595. */
  13596. var assignIn = createAssigner(function(object, source) {
  13597. copyObject(source, keysIn(source), object);
  13598. });
  13599. /**
  13600. * This method is like `_.assignIn` except that it accepts `customizer`
  13601. * which is invoked to produce the assigned values. If `customizer` returns
  13602. * `undefined`, assignment is handled by the method instead. The `customizer`
  13603. * is invoked with five arguments: (objValue, srcValue, key, object, source).
  13604. *
  13605. * **Note:** This method mutates `object`.
  13606. *
  13607. * @static
  13608. * @memberOf _
  13609. * @since 4.0.0
  13610. * @alias extendWith
  13611. * @category Object
  13612. * @param {Object} object The destination object.
  13613. * @param {...Object} sources The source objects.
  13614. * @param {Function} [customizer] The function to customize assigned values.
  13615. * @returns {Object} Returns `object`.
  13616. * @see _.assignWith
  13617. * @example
  13618. *
  13619. * function customizer(objValue, srcValue) {
  13620. * return _.isUndefined(objValue) ? srcValue : objValue;
  13621. * }
  13622. *
  13623. * var defaults = _.partialRight(_.assignInWith, customizer);
  13624. *
  13625. * defaults({ 'a': 1 }, { 'b': 2 }, { 'a': 3 });
  13626. * // => { 'a': 1, 'b': 2 }
  13627. */
  13628. var assignInWith = createAssigner(function(object, source, srcIndex, customizer) {
  13629. copyObject(source, keysIn(source), object, customizer);
  13630. });
  13631. /**
  13632. * This method is like `_.assign` except that it accepts `customizer`
  13633. * which is invoked to produce the assigned values. If `customizer` returns
  13634. * `undefined`, assignment is handled by the method instead. The `customizer`
  13635. * is invoked with five arguments: (objValue, srcValue, key, object, source).
  13636. *
  13637. * **Note:** This method mutates `object`.
  13638. *
  13639. * @static
  13640. * @memberOf _
  13641. * @since 4.0.0
  13642. * @category Object
  13643. * @param {Object} object The destination object.
  13644. * @param {...Object} sources The source objects.
  13645. * @param {Function} [customizer] The function to customize assigned values.
  13646. * @returns {Object} Returns `object`.
  13647. * @see _.assignInWith
  13648. * @example
  13649. *
  13650. * function customizer(objValue, srcValue) {
  13651. * return _.isUndefined(objValue) ? srcValue : objValue;
  13652. * }
  13653. *
  13654. * var defaults = _.partialRight(_.assignWith, customizer);
  13655. *
  13656. * defaults({ 'a': 1 }, { 'b': 2 }, { 'a': 3 });
  13657. * // => { 'a': 1, 'b': 2 }
  13658. */
  13659. var assignWith = createAssigner(function(object, source, srcIndex, customizer) {
  13660. copyObject(source, keys(source), object, customizer);
  13661. });
  13662. /**
  13663. * Creates an array of values corresponding to `paths` of `object`.
  13664. *
  13665. * @static
  13666. * @memberOf _
  13667. * @since 1.0.0
  13668. * @category Object
  13669. * @param {Object} object The object to iterate over.
  13670. * @param {...(string|string[])} [paths] The property paths to pick.
  13671. * @returns {Array} Returns the picked values.
  13672. * @example
  13673. *
  13674. * var object = { 'a': [{ 'b': { 'c': 3 } }, 4] };
  13675. *
  13676. * _.at(object, ['a[0].b.c', 'a[1]']);
  13677. * // => [3, 4]
  13678. */
  13679. var at = flatRest(baseAt);
  13680. /**
  13681. * Creates an object that inherits from the `prototype` object. If a
  13682. * `properties` object is given, its own enumerable string keyed properties
  13683. * are assigned to the created object.
  13684. *
  13685. * @static
  13686. * @memberOf _
  13687. * @since 2.3.0
  13688. * @category Object
  13689. * @param {Object} prototype The object to inherit from.
  13690. * @param {Object} [properties] The properties to assign to the object.
  13691. * @returns {Object} Returns the new object.
  13692. * @example
  13693. *
  13694. * function Shape() {
  13695. * this.x = 0;
  13696. * this.y = 0;
  13697. * }
  13698. *
  13699. * function Circle() {
  13700. * Shape.call(this);
  13701. * }
  13702. *
  13703. * Circle.prototype = _.create(Shape.prototype, {
  13704. * 'constructor': Circle
  13705. * });
  13706. *
  13707. * var circle = new Circle;
  13708. * circle instanceof Circle;
  13709. * // => true
  13710. *
  13711. * circle instanceof Shape;
  13712. * // => true
  13713. */
  13714. function create(prototype, properties) {
  13715. var result = baseCreate(prototype);
  13716. return properties == null ? result : baseAssign(result, properties);
  13717. }
  13718. /**
  13719. * Assigns own and inherited enumerable string keyed properties of source
  13720. * objects to the destination object for all destination properties that
  13721. * resolve to `undefined`. Source objects are applied from left to right.
  13722. * Once a property is set, additional values of the same property are ignored.
  13723. *
  13724. * **Note:** This method mutates `object`.
  13725. *
  13726. * @static
  13727. * @since 0.1.0
  13728. * @memberOf _
  13729. * @category Object
  13730. * @param {Object} object The destination object.
  13731. * @param {...Object} [sources] The source objects.
  13732. * @returns {Object} Returns `object`.
  13733. * @see _.defaultsDeep
  13734. * @example
  13735. *
  13736. * _.defaults({ 'a': 1 }, { 'b': 2 }, { 'a': 3 });
  13737. * // => { 'a': 1, 'b': 2 }
  13738. */
  13739. var defaults = baseRest(function(object, sources) {
  13740. object = Object(object);
  13741. var index = -1;
  13742. var length = sources.length;
  13743. var guard = length > 2 ? sources[2] : undefined;
  13744. if (guard && isIterateeCall(sources[0], sources[1], guard)) {
  13745. length = 1;
  13746. }
  13747. while (++index < length) {
  13748. var source = sources[index];
  13749. var props = keysIn(source);
  13750. var propsIndex = -1;
  13751. var propsLength = props.length;
  13752. while (++propsIndex < propsLength) {
  13753. var key = props[propsIndex];
  13754. var value = object[key];
  13755. if (value === undefined ||
  13756. (eq(value, objectProto[key]) && !hasOwnProperty.call(object, key))) {
  13757. object[key] = source[key];
  13758. }
  13759. }
  13760. }
  13761. return object;
  13762. });
  13763. /**
  13764. * This method is like `_.defaults` except that it recursively assigns
  13765. * default properties.
  13766. *
  13767. * **Note:** This method mutates `object`.
  13768. *
  13769. * @static
  13770. * @memberOf _
  13771. * @since 3.10.0
  13772. * @category Object
  13773. * @param {Object} object The destination object.
  13774. * @param {...Object} [sources] The source objects.
  13775. * @returns {Object} Returns `object`.
  13776. * @see _.defaults
  13777. * @example
  13778. *
  13779. * _.defaultsDeep({ 'a': { 'b': 2 } }, { 'a': { 'b': 1, 'c': 3 } });
  13780. * // => { 'a': { 'b': 2, 'c': 3 } }
  13781. */
  13782. var defaultsDeep = baseRest(function(args) {
  13783. args.push(undefined, customDefaultsMerge);
  13784. return apply(mergeWith, undefined, args);
  13785. });
  13786. /**
  13787. * This method is like `_.find` except that it returns the key of the first
  13788. * element `predicate` returns truthy for instead of the element itself.
  13789. *
  13790. * @static
  13791. * @memberOf _
  13792. * @since 1.1.0
  13793. * @category Object
  13794. * @param {Object} object The object to inspect.
  13795. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  13796. * @returns {string|undefined} Returns the key of the matched element,
  13797. * else `undefined`.
  13798. * @example
  13799. *
  13800. * var users = {
  13801. * 'barney': { 'age': 36, 'active': true },
  13802. * 'fred': { 'age': 40, 'active': false },
  13803. * 'pebbles': { 'age': 1, 'active': true }
  13804. * };
  13805. *
  13806. * _.findKey(users, function(o) { return o.age < 40; });
  13807. * // => 'barney' (iteration order is not guaranteed)
  13808. *
  13809. * // The `_.matches` iteratee shorthand.
  13810. * _.findKey(users, { 'age': 1, 'active': true });
  13811. * // => 'pebbles'
  13812. *
  13813. * // The `_.matchesProperty` iteratee shorthand.
  13814. * _.findKey(users, ['active', false]);
  13815. * // => 'fred'
  13816. *
  13817. * // The `_.property` iteratee shorthand.
  13818. * _.findKey(users, 'active');
  13819. * // => 'barney'
  13820. */
  13821. function findKey(object, predicate) {
  13822. return baseFindKey(object, getIteratee(predicate, 3), baseForOwn);
  13823. }
  13824. /**
  13825. * This method is like `_.findKey` except that it iterates over elements of
  13826. * a collection in the opposite order.
  13827. *
  13828. * @static
  13829. * @memberOf _
  13830. * @since 2.0.0
  13831. * @category Object
  13832. * @param {Object} object The object to inspect.
  13833. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  13834. * @returns {string|undefined} Returns the key of the matched element,
  13835. * else `undefined`.
  13836. * @example
  13837. *
  13838. * var users = {
  13839. * 'barney': { 'age': 36, 'active': true },
  13840. * 'fred': { 'age': 40, 'active': false },
  13841. * 'pebbles': { 'age': 1, 'active': true }
  13842. * };
  13843. *
  13844. * _.findLastKey(users, function(o) { return o.age < 40; });
  13845. * // => returns 'pebbles' assuming `_.findKey` returns 'barney'
  13846. *
  13847. * // The `_.matches` iteratee shorthand.
  13848. * _.findLastKey(users, { 'age': 36, 'active': true });
  13849. * // => 'barney'
  13850. *
  13851. * // The `_.matchesProperty` iteratee shorthand.
  13852. * _.findLastKey(users, ['active', false]);
  13853. * // => 'fred'
  13854. *
  13855. * // The `_.property` iteratee shorthand.
  13856. * _.findLastKey(users, 'active');
  13857. * // => 'pebbles'
  13858. */
  13859. function findLastKey(object, predicate) {
  13860. return baseFindKey(object, getIteratee(predicate, 3), baseForOwnRight);
  13861. }
  13862. /**
  13863. * Iterates over own and inherited enumerable string keyed properties of an
  13864. * object and invokes `iteratee` for each property. The iteratee is invoked
  13865. * with three arguments: (value, key, object). Iteratee functions may exit
  13866. * iteration early by explicitly returning `false`.
  13867. *
  13868. * @static
  13869. * @memberOf _
  13870. * @since 0.3.0
  13871. * @category Object
  13872. * @param {Object} object The object to iterate over.
  13873. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  13874. * @returns {Object} Returns `object`.
  13875. * @see _.forInRight
  13876. * @example
  13877. *
  13878. * function Foo() {
  13879. * this.a = 1;
  13880. * this.b = 2;
  13881. * }
  13882. *
  13883. * Foo.prototype.c = 3;
  13884. *
  13885. * _.forIn(new Foo, function(value, key) {
  13886. * console.log(key);
  13887. * });
  13888. * // => Logs 'a', 'b', then 'c' (iteration order is not guaranteed).
  13889. */
  13890. function forIn(object, iteratee) {
  13891. return object == null
  13892. ? object
  13893. : baseFor(object, getIteratee(iteratee, 3), keysIn);
  13894. }
  13895. /**
  13896. * This method is like `_.forIn` except that it iterates over properties of
  13897. * `object` in the opposite order.
  13898. *
  13899. * @static
  13900. * @memberOf _
  13901. * @since 2.0.0
  13902. * @category Object
  13903. * @param {Object} object The object to iterate over.
  13904. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  13905. * @returns {Object} Returns `object`.
  13906. * @see _.forIn
  13907. * @example
  13908. *
  13909. * function Foo() {
  13910. * this.a = 1;
  13911. * this.b = 2;
  13912. * }
  13913. *
  13914. * Foo.prototype.c = 3;
  13915. *
  13916. * _.forInRight(new Foo, function(value, key) {
  13917. * console.log(key);
  13918. * });
  13919. * // => Logs 'c', 'b', then 'a' assuming `_.forIn` logs 'a', 'b', then 'c'.
  13920. */
  13921. function forInRight(object, iteratee) {
  13922. return object == null
  13923. ? object
  13924. : baseForRight(object, getIteratee(iteratee, 3), keysIn);
  13925. }
  13926. /**
  13927. * Iterates over own enumerable string keyed properties of an object and
  13928. * invokes `iteratee` for each property. The iteratee is invoked with three
  13929. * arguments: (value, key, object). Iteratee functions may exit iteration
  13930. * early by explicitly returning `false`.
  13931. *
  13932. * @static
  13933. * @memberOf _
  13934. * @since 0.3.0
  13935. * @category Object
  13936. * @param {Object} object The object to iterate over.
  13937. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  13938. * @returns {Object} Returns `object`.
  13939. * @see _.forOwnRight
  13940. * @example
  13941. *
  13942. * function Foo() {
  13943. * this.a = 1;
  13944. * this.b = 2;
  13945. * }
  13946. *
  13947. * Foo.prototype.c = 3;
  13948. *
  13949. * _.forOwn(new Foo, function(value, key) {
  13950. * console.log(key);
  13951. * });
  13952. * // => Logs 'a' then 'b' (iteration order is not guaranteed).
  13953. */
  13954. function forOwn(object, iteratee) {
  13955. return object && baseForOwn(object, getIteratee(iteratee, 3));
  13956. }
  13957. /**
  13958. * This method is like `_.forOwn` except that it iterates over properties of
  13959. * `object` in the opposite order.
  13960. *
  13961. * @static
  13962. * @memberOf _
  13963. * @since 2.0.0
  13964. * @category Object
  13965. * @param {Object} object The object to iterate over.
  13966. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  13967. * @returns {Object} Returns `object`.
  13968. * @see _.forOwn
  13969. * @example
  13970. *
  13971. * function Foo() {
  13972. * this.a = 1;
  13973. * this.b = 2;
  13974. * }
  13975. *
  13976. * Foo.prototype.c = 3;
  13977. *
  13978. * _.forOwnRight(new Foo, function(value, key) {
  13979. * console.log(key);
  13980. * });
  13981. * // => Logs 'b' then 'a' assuming `_.forOwn` logs 'a' then 'b'.
  13982. */
  13983. function forOwnRight(object, iteratee) {
  13984. return object && baseForOwnRight(object, getIteratee(iteratee, 3));
  13985. }
  13986. /**
  13987. * Creates an array of function property names from own enumerable properties
  13988. * of `object`.
  13989. *
  13990. * @static
  13991. * @since 0.1.0
  13992. * @memberOf _
  13993. * @category Object
  13994. * @param {Object} object The object to inspect.
  13995. * @returns {Array} Returns the function names.
  13996. * @see _.functionsIn
  13997. * @example
  13998. *
  13999. * function Foo() {
  14000. * this.a = _.constant('a');
  14001. * this.b = _.constant('b');
  14002. * }
  14003. *
  14004. * Foo.prototype.c = _.constant('c');
  14005. *
  14006. * _.functions(new Foo);
  14007. * // => ['a', 'b']
  14008. */
  14009. function functions(object) {
  14010. return object == null ? [] : baseFunctions(object, keys(object));
  14011. }
  14012. /**
  14013. * Creates an array of function property names from own and inherited
  14014. * enumerable properties of `object`.
  14015. *
  14016. * @static
  14017. * @memberOf _
  14018. * @since 4.0.0
  14019. * @category Object
  14020. * @param {Object} object The object to inspect.
  14021. * @returns {Array} Returns the function names.
  14022. * @see _.functions
  14023. * @example
  14024. *
  14025. * function Foo() {
  14026. * this.a = _.constant('a');
  14027. * this.b = _.constant('b');
  14028. * }
  14029. *
  14030. * Foo.prototype.c = _.constant('c');
  14031. *
  14032. * _.functionsIn(new Foo);
  14033. * // => ['a', 'b', 'c']
  14034. */
  14035. function functionsIn(object) {
  14036. return object == null ? [] : baseFunctions(object, keysIn(object));
  14037. }
  14038. /**
  14039. * Gets the value at `path` of `object`. If the resolved value is
  14040. * `undefined`, the `defaultValue` is returned in its place.
  14041. *
  14042. * @static
  14043. * @memberOf _
  14044. * @since 3.7.0
  14045. * @category Object
  14046. * @param {Object} object The object to query.
  14047. * @param {Array|string} path The path of the property to get.
  14048. * @param {*} [defaultValue] The value returned for `undefined` resolved values.
  14049. * @returns {*} Returns the resolved value.
  14050. * @example
  14051. *
  14052. * var object = { 'a': [{ 'b': { 'c': 3 } }] };
  14053. *
  14054. * _.get(object, 'a[0].b.c');
  14055. * // => 3
  14056. *
  14057. * _.get(object, ['a', '0', 'b', 'c']);
  14058. * // => 3
  14059. *
  14060. * _.get(object, 'a.b.c', 'default');
  14061. * // => 'default'
  14062. */
  14063. function get(object, path, defaultValue) {
  14064. var result = object == null ? undefined : baseGet(object, path);
  14065. return result === undefined ? defaultValue : result;
  14066. }
  14067. /**
  14068. * Checks if `path` is a direct property of `object`.
  14069. *
  14070. * @static
  14071. * @since 0.1.0
  14072. * @memberOf _
  14073. * @category Object
  14074. * @param {Object} object The object to query.
  14075. * @param {Array|string} path The path to check.
  14076. * @returns {boolean} Returns `true` if `path` exists, else `false`.
  14077. * @example
  14078. *
  14079. * var object = { 'a': { 'b': 2 } };
  14080. * var other = _.create({ 'a': _.create({ 'b': 2 }) });
  14081. *
  14082. * _.has(object, 'a');
  14083. * // => true
  14084. *
  14085. * _.has(object, 'a.b');
  14086. * // => true
  14087. *
  14088. * _.has(object, ['a', 'b']);
  14089. * // => true
  14090. *
  14091. * _.has(other, 'a');
  14092. * // => false
  14093. */
  14094. function has(object, path) {
  14095. return object != null && hasPath(object, path, baseHas);
  14096. }
  14097. /**
  14098. * Checks if `path` is a direct or inherited property of `object`.
  14099. *
  14100. * @static
  14101. * @memberOf _
  14102. * @since 4.0.0
  14103. * @category Object
  14104. * @param {Object} object The object to query.
  14105. * @param {Array|string} path The path to check.
  14106. * @returns {boolean} Returns `true` if `path` exists, else `false`.
  14107. * @example
  14108. *
  14109. * var object = _.create({ 'a': _.create({ 'b': 2 }) });
  14110. *
  14111. * _.hasIn(object, 'a');
  14112. * // => true
  14113. *
  14114. * _.hasIn(object, 'a.b');
  14115. * // => true
  14116. *
  14117. * _.hasIn(object, ['a', 'b']);
  14118. * // => true
  14119. *
  14120. * _.hasIn(object, 'b');
  14121. * // => false
  14122. */
  14123. function hasIn(object, path) {
  14124. return object != null && hasPath(object, path, baseHasIn);
  14125. }
  14126. /**
  14127. * Creates an object composed of the inverted keys and values of `object`.
  14128. * If `object` contains duplicate values, subsequent values overwrite
  14129. * property assignments of previous values.
  14130. *
  14131. * @static
  14132. * @memberOf _
  14133. * @since 0.7.0
  14134. * @category Object
  14135. * @param {Object} object The object to invert.
  14136. * @returns {Object} Returns the new inverted object.
  14137. * @example
  14138. *
  14139. * var object = { 'a': 1, 'b': 2, 'c': 1 };
  14140. *
  14141. * _.invert(object);
  14142. * // => { '1': 'c', '2': 'b' }
  14143. */
  14144. var invert = createInverter(function(result, value, key) {
  14145. if (value != null &&
  14146. typeof value.toString != 'function') {
  14147. value = nativeObjectToString.call(value);
  14148. }
  14149. result[value] = key;
  14150. }, constant(identity));
  14151. /**
  14152. * This method is like `_.invert` except that the inverted object is generated
  14153. * from the results of running each element of `object` thru `iteratee`. The
  14154. * corresponding inverted value of each inverted key is an array of keys
  14155. * responsible for generating the inverted value. The iteratee is invoked
  14156. * with one argument: (value).
  14157. *
  14158. * @static
  14159. * @memberOf _
  14160. * @since 4.1.0
  14161. * @category Object
  14162. * @param {Object} object The object to invert.
  14163. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  14164. * @returns {Object} Returns the new inverted object.
  14165. * @example
  14166. *
  14167. * var object = { 'a': 1, 'b': 2, 'c': 1 };
  14168. *
  14169. * _.invertBy(object);
  14170. * // => { '1': ['a', 'c'], '2': ['b'] }
  14171. *
  14172. * _.invertBy(object, function(value) {
  14173. * return 'group' + value;
  14174. * });
  14175. * // => { 'group1': ['a', 'c'], 'group2': ['b'] }
  14176. */
  14177. var invertBy = createInverter(function(result, value, key) {
  14178. if (value != null &&
  14179. typeof value.toString != 'function') {
  14180. value = nativeObjectToString.call(value);
  14181. }
  14182. if (hasOwnProperty.call(result, value)) {
  14183. result[value].push(key);
  14184. } else {
  14185. result[value] = [key];
  14186. }
  14187. }, getIteratee);
  14188. /**
  14189. * Invokes the method at `path` of `object`.
  14190. *
  14191. * @static
  14192. * @memberOf _
  14193. * @since 4.0.0
  14194. * @category Object
  14195. * @param {Object} object The object to query.
  14196. * @param {Array|string} path The path of the method to invoke.
  14197. * @param {...*} [args] The arguments to invoke the method with.
  14198. * @returns {*} Returns the result of the invoked method.
  14199. * @example
  14200. *
  14201. * var object = { 'a': [{ 'b': { 'c': [1, 2, 3, 4] } }] };
  14202. *
  14203. * _.invoke(object, 'a[0].b.c.slice', 1, 3);
  14204. * // => [2, 3]
  14205. */
  14206. var invoke = baseRest(baseInvoke);
  14207. /**
  14208. * Creates an array of the own enumerable property names of `object`.
  14209. *
  14210. * **Note:** Non-object values are coerced to objects. See the
  14211. * [ES spec](http://ecma-international.org/ecma-262/7.0/#sec-object.keys)
  14212. * for more details.
  14213. *
  14214. * @static
  14215. * @since 0.1.0
  14216. * @memberOf _
  14217. * @category Object
  14218. * @param {Object} object The object to query.
  14219. * @returns {Array} Returns the array of property names.
  14220. * @example
  14221. *
  14222. * function Foo() {
  14223. * this.a = 1;
  14224. * this.b = 2;
  14225. * }
  14226. *
  14227. * Foo.prototype.c = 3;
  14228. *
  14229. * _.keys(new Foo);
  14230. * // => ['a', 'b'] (iteration order is not guaranteed)
  14231. *
  14232. * _.keys('hi');
  14233. * // => ['0', '1']
  14234. */
  14235. function keys(object) {
  14236. return isArrayLike(object) ? arrayLikeKeys(object) : baseKeys(object);
  14237. }
  14238. /**
  14239. * Creates an array of the own and inherited enumerable property names of `object`.
  14240. *
  14241. * **Note:** Non-object values are coerced to objects.
  14242. *
  14243. * @static
  14244. * @memberOf _
  14245. * @since 3.0.0
  14246. * @category Object
  14247. * @param {Object} object The object to query.
  14248. * @returns {Array} Returns the array of property names.
  14249. * @example
  14250. *
  14251. * function Foo() {
  14252. * this.a = 1;
  14253. * this.b = 2;
  14254. * }
  14255. *
  14256. * Foo.prototype.c = 3;
  14257. *
  14258. * _.keysIn(new Foo);
  14259. * // => ['a', 'b', 'c'] (iteration order is not guaranteed)
  14260. */
  14261. function keysIn(object) {
  14262. return isArrayLike(object) ? arrayLikeKeys(object, true) : baseKeysIn(object);
  14263. }
  14264. /**
  14265. * The opposite of `_.mapValues`; this method creates an object with the
  14266. * same values as `object` and keys generated by running each own enumerable
  14267. * string keyed property of `object` thru `iteratee`. The iteratee is invoked
  14268. * with three arguments: (value, key, object).
  14269. *
  14270. * @static
  14271. * @memberOf _
  14272. * @since 3.8.0
  14273. * @category Object
  14274. * @param {Object} object The object to iterate over.
  14275. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  14276. * @returns {Object} Returns the new mapped object.
  14277. * @see _.mapValues
  14278. * @example
  14279. *
  14280. * _.mapKeys({ 'a': 1, 'b': 2 }, function(value, key) {
  14281. * return key + value;
  14282. * });
  14283. * // => { 'a1': 1, 'b2': 2 }
  14284. */
  14285. function mapKeys(object, iteratee) {
  14286. var result = {};
  14287. iteratee = getIteratee(iteratee, 3);
  14288. baseForOwn(object, function(value, key, object) {
  14289. baseAssignValue(result, iteratee(value, key, object), value);
  14290. });
  14291. return result;
  14292. }
  14293. /**
  14294. * Creates an object with the same keys as `object` and values generated
  14295. * by running each own enumerable string keyed property of `object` thru
  14296. * `iteratee`. The iteratee is invoked with three arguments:
  14297. * (value, key, object).
  14298. *
  14299. * @static
  14300. * @memberOf _
  14301. * @since 2.4.0
  14302. * @category Object
  14303. * @param {Object} object The object to iterate over.
  14304. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  14305. * @returns {Object} Returns the new mapped object.
  14306. * @see _.mapKeys
  14307. * @example
  14308. *
  14309. * var users = {
  14310. * 'fred': { 'user': 'fred', 'age': 40 },
  14311. * 'pebbles': { 'user': 'pebbles', 'age': 1 }
  14312. * };
  14313. *
  14314. * _.mapValues(users, function(o) { return o.age; });
  14315. * // => { 'fred': 40, 'pebbles': 1 } (iteration order is not guaranteed)
  14316. *
  14317. * // The `_.property` iteratee shorthand.
  14318. * _.mapValues(users, 'age');
  14319. * // => { 'fred': 40, 'pebbles': 1 } (iteration order is not guaranteed)
  14320. */
  14321. function mapValues(object, iteratee) {
  14322. var result = {};
  14323. iteratee = getIteratee(iteratee, 3);
  14324. baseForOwn(object, function(value, key, object) {
  14325. baseAssignValue(result, key, iteratee(value, key, object));
  14326. });
  14327. return result;
  14328. }
  14329. /**
  14330. * This method is like `_.assign` except that it recursively merges own and
  14331. * inherited enumerable string keyed properties of source objects into the
  14332. * destination object. Source properties that resolve to `undefined` are
  14333. * skipped if a destination value exists. Array and plain object properties
  14334. * are merged recursively. Other objects and value types are overridden by
  14335. * assignment. Source objects are applied from left to right. Subsequent
  14336. * sources overwrite property assignments of previous sources.
  14337. *
  14338. * **Note:** This method mutates `object`.
  14339. *
  14340. * @static
  14341. * @memberOf _
  14342. * @since 0.5.0
  14343. * @category Object
  14344. * @param {Object} object The destination object.
  14345. * @param {...Object} [sources] The source objects.
  14346. * @returns {Object} Returns `object`.
  14347. * @example
  14348. *
  14349. * var object = {
  14350. * 'a': [{ 'b': 2 }, { 'd': 4 }]
  14351. * };
  14352. *
  14353. * var other = {
  14354. * 'a': [{ 'c': 3 }, { 'e': 5 }]
  14355. * };
  14356. *
  14357. * _.merge(object, other);
  14358. * // => { 'a': [{ 'b': 2, 'c': 3 }, { 'd': 4, 'e': 5 }] }
  14359. */
  14360. var merge = createAssigner(function(object, source, srcIndex) {
  14361. baseMerge(object, source, srcIndex);
  14362. });
  14363. /**
  14364. * This method is like `_.merge` except that it accepts `customizer` which
  14365. * is invoked to produce the merged values of the destination and source
  14366. * properties. If `customizer` returns `undefined`, merging is handled by the
  14367. * method instead. The `customizer` is invoked with six arguments:
  14368. * (objValue, srcValue, key, object, source, stack).
  14369. *
  14370. * **Note:** This method mutates `object`.
  14371. *
  14372. * @static
  14373. * @memberOf _
  14374. * @since 4.0.0
  14375. * @category Object
  14376. * @param {Object} object The destination object.
  14377. * @param {...Object} sources The source objects.
  14378. * @param {Function} customizer The function to customize assigned values.
  14379. * @returns {Object} Returns `object`.
  14380. * @example
  14381. *
  14382. * function customizer(objValue, srcValue) {
  14383. * if (_.isArray(objValue)) {
  14384. * return objValue.concat(srcValue);
  14385. * }
  14386. * }
  14387. *
  14388. * var object = { 'a': [1], 'b': [2] };
  14389. * var other = { 'a': [3], 'b': [4] };
  14390. *
  14391. * _.mergeWith(object, other, customizer);
  14392. * // => { 'a': [1, 3], 'b': [2, 4] }
  14393. */
  14394. var mergeWith = createAssigner(function(object, source, srcIndex, customizer) {
  14395. baseMerge(object, source, srcIndex, customizer);
  14396. });
  14397. /**
  14398. * The opposite of `_.pick`; this method creates an object composed of the
  14399. * own and inherited enumerable property paths of `object` that are not omitted.
  14400. *
  14401. * **Note:** This method is considerably slower than `_.pick`.
  14402. *
  14403. * @static
  14404. * @since 0.1.0
  14405. * @memberOf _
  14406. * @category Object
  14407. * @param {Object} object The source object.
  14408. * @param {...(string|string[])} [paths] The property paths to omit.
  14409. * @returns {Object} Returns the new object.
  14410. * @example
  14411. *
  14412. * var object = { 'a': 1, 'b': '2', 'c': 3 };
  14413. *
  14414. * _.omit(object, ['a', 'c']);
  14415. * // => { 'b': '2' }
  14416. */
  14417. var omit = flatRest(function(object, paths) {
  14418. var result = {};
  14419. if (object == null) {
  14420. return result;
  14421. }
  14422. var isDeep = false;
  14423. paths = arrayMap(paths, function(path) {
  14424. path = castPath(path, object);
  14425. isDeep || (isDeep = path.length > 1);
  14426. return path;
  14427. });
  14428. copyObject(object, getAllKeysIn(object), result);
  14429. if (isDeep) {
  14430. result = baseClone(result, CLONE_DEEP_FLAG | CLONE_FLAT_FLAG | CLONE_SYMBOLS_FLAG, customOmitClone);
  14431. }
  14432. var length = paths.length;
  14433. while (length--) {
  14434. baseUnset(result, paths[length]);
  14435. }
  14436. return result;
  14437. });
  14438. /**
  14439. * The opposite of `_.pickBy`; this method creates an object composed of
  14440. * the own and inherited enumerable string keyed properties of `object` that
  14441. * `predicate` doesn't return truthy for. The predicate is invoked with two
  14442. * arguments: (value, key).
  14443. *
  14444. * @static
  14445. * @memberOf _
  14446. * @since 4.0.0
  14447. * @category Object
  14448. * @param {Object} object The source object.
  14449. * @param {Function} [predicate=_.identity] The function invoked per property.
  14450. * @returns {Object} Returns the new object.
  14451. * @example
  14452. *
  14453. * var object = { 'a': 1, 'b': '2', 'c': 3 };
  14454. *
  14455. * _.omitBy(object, _.isNumber);
  14456. * // => { 'b': '2' }
  14457. */
  14458. function omitBy(object, predicate) {
  14459. return pickBy(object, negate(getIteratee(predicate)));
  14460. }
  14461. /**
  14462. * Creates an object composed of the picked `object` properties.
  14463. *
  14464. * @static
  14465. * @since 0.1.0
  14466. * @memberOf _
  14467. * @category Object
  14468. * @param {Object} object The source object.
  14469. * @param {...(string|string[])} [paths] The property paths to pick.
  14470. * @returns {Object} Returns the new object.
  14471. * @example
  14472. *
  14473. * var object = { 'a': 1, 'b': '2', 'c': 3 };
  14474. *
  14475. * _.pick(object, ['a', 'c']);
  14476. * // => { 'a': 1, 'c': 3 }
  14477. */
  14478. var pick = flatRest(function(object, paths) {
  14479. return object == null ? {} : basePick(object, paths);
  14480. });
  14481. /**
  14482. * Creates an object composed of the `object` properties `predicate` returns
  14483. * truthy for. The predicate is invoked with two arguments: (value, key).
  14484. *
  14485. * @static
  14486. * @memberOf _
  14487. * @since 4.0.0
  14488. * @category Object
  14489. * @param {Object} object The source object.
  14490. * @param {Function} [predicate=_.identity] The function invoked per property.
  14491. * @returns {Object} Returns the new object.
  14492. * @example
  14493. *
  14494. * var object = { 'a': 1, 'b': '2', 'c': 3 };
  14495. *
  14496. * _.pickBy(object, _.isNumber);
  14497. * // => { 'a': 1, 'c': 3 }
  14498. */
  14499. function pickBy(object, predicate) {
  14500. if (object == null) {
  14501. return {};
  14502. }
  14503. var props = arrayMap(getAllKeysIn(object), function(prop) {
  14504. return [prop];
  14505. });
  14506. predicate = getIteratee(predicate);
  14507. return basePickBy(object, props, function(value, path) {
  14508. return predicate(value, path[0]);
  14509. });
  14510. }
  14511. /**
  14512. * This method is like `_.get` except that if the resolved value is a
  14513. * function it's invoked with the `this` binding of its parent object and
  14514. * its result is returned.
  14515. *
  14516. * @static
  14517. * @since 0.1.0
  14518. * @memberOf _
  14519. * @category Object
  14520. * @param {Object} object The object to query.
  14521. * @param {Array|string} path The path of the property to resolve.
  14522. * @param {*} [defaultValue] The value returned for `undefined` resolved values.
  14523. * @returns {*} Returns the resolved value.
  14524. * @example
  14525. *
  14526. * var object = { 'a': [{ 'b': { 'c1': 3, 'c2': _.constant(4) } }] };
  14527. *
  14528. * _.result(object, 'a[0].b.c1');
  14529. * // => 3
  14530. *
  14531. * _.result(object, 'a[0].b.c2');
  14532. * // => 4
  14533. *
  14534. * _.result(object, 'a[0].b.c3', 'default');
  14535. * // => 'default'
  14536. *
  14537. * _.result(object, 'a[0].b.c3', _.constant('default'));
  14538. * // => 'default'
  14539. */
  14540. function result(object, path, defaultValue) {
  14541. path = castPath(path, object);
  14542. var index = -1,
  14543. length = path.length;
  14544. // Ensure the loop is entered when path is empty.
  14545. if (!length) {
  14546. length = 1;
  14547. object = undefined;
  14548. }
  14549. while (++index < length) {
  14550. var value = object == null ? undefined : object[toKey(path[index])];
  14551. if (value === undefined) {
  14552. index = length;
  14553. value = defaultValue;
  14554. }
  14555. object = isFunction(value) ? value.call(object) : value;
  14556. }
  14557. return object;
  14558. }
  14559. /**
  14560. * Sets the value at `path` of `object`. If a portion of `path` doesn't exist,
  14561. * it's created. Arrays are created for missing index properties while objects
  14562. * are created for all other missing properties. Use `_.setWith` to customize
  14563. * `path` creation.
  14564. *
  14565. * **Note:** This method mutates `object`.
  14566. *
  14567. * @static
  14568. * @memberOf _
  14569. * @since 3.7.0
  14570. * @category Object
  14571. * @param {Object} object The object to modify.
  14572. * @param {Array|string} path The path of the property to set.
  14573. * @param {*} value The value to set.
  14574. * @returns {Object} Returns `object`.
  14575. * @example
  14576. *
  14577. * var object = { 'a': [{ 'b': { 'c': 3 } }] };
  14578. *
  14579. * _.set(object, 'a[0].b.c', 4);
  14580. * console.log(object.a[0].b.c);
  14581. * // => 4
  14582. *
  14583. * _.set(object, ['x', '0', 'y', 'z'], 5);
  14584. * console.log(object.x[0].y.z);
  14585. * // => 5
  14586. */
  14587. function set(object, path, value) {
  14588. return object == null ? object : baseSet(object, path, value);
  14589. }
  14590. /**
  14591. * This method is like `_.set` except that it accepts `customizer` which is
  14592. * invoked to produce the objects of `path`. If `customizer` returns `undefined`
  14593. * path creation is handled by the method instead. The `customizer` is invoked
  14594. * with three arguments: (nsValue, key, nsObject).
  14595. *
  14596. * **Note:** This method mutates `object`.
  14597. *
  14598. * @static
  14599. * @memberOf _
  14600. * @since 4.0.0
  14601. * @category Object
  14602. * @param {Object} object The object to modify.
  14603. * @param {Array|string} path The path of the property to set.
  14604. * @param {*} value The value to set.
  14605. * @param {Function} [customizer] The function to customize assigned values.
  14606. * @returns {Object} Returns `object`.
  14607. * @example
  14608. *
  14609. * var object = {};
  14610. *
  14611. * _.setWith(object, '[0][1]', 'a', Object);
  14612. * // => { '0': { '1': 'a' } }
  14613. */
  14614. function setWith(object, path, value, customizer) {
  14615. customizer = typeof customizer == 'function' ? customizer : undefined;
  14616. return object == null ? object : baseSet(object, path, value, customizer);
  14617. }
  14618. /**
  14619. * Creates an array of own enumerable string keyed-value pairs for `object`
  14620. * which can be consumed by `_.fromPairs`. If `object` is a map or set, its
  14621. * entries are returned.
  14622. *
  14623. * @static
  14624. * @memberOf _
  14625. * @since 4.0.0
  14626. * @alias entries
  14627. * @category Object
  14628. * @param {Object} object The object to query.
  14629. * @returns {Array} Returns the key-value pairs.
  14630. * @example
  14631. *
  14632. * function Foo() {
  14633. * this.a = 1;
  14634. * this.b = 2;
  14635. * }
  14636. *
  14637. * Foo.prototype.c = 3;
  14638. *
  14639. * _.toPairs(new Foo);
  14640. * // => [['a', 1], ['b', 2]] (iteration order is not guaranteed)
  14641. */
  14642. var toPairs = createToPairs(keys);
  14643. /**
  14644. * Creates an array of own and inherited enumerable string keyed-value pairs
  14645. * for `object` which can be consumed by `_.fromPairs`. If `object` is a map
  14646. * or set, its entries are returned.
  14647. *
  14648. * @static
  14649. * @memberOf _
  14650. * @since 4.0.0
  14651. * @alias entriesIn
  14652. * @category Object
  14653. * @param {Object} object The object to query.
  14654. * @returns {Array} Returns the key-value pairs.
  14655. * @example
  14656. *
  14657. * function Foo() {
  14658. * this.a = 1;
  14659. * this.b = 2;
  14660. * }
  14661. *
  14662. * Foo.prototype.c = 3;
  14663. *
  14664. * _.toPairsIn(new Foo);
  14665. * // => [['a', 1], ['b', 2], ['c', 3]] (iteration order is not guaranteed)
  14666. */
  14667. var toPairsIn = createToPairs(keysIn);
  14668. /**
  14669. * An alternative to `_.reduce`; this method transforms `object` to a new
  14670. * `accumulator` object which is the result of running each of its own
  14671. * enumerable string keyed properties thru `iteratee`, with each invocation
  14672. * potentially mutating the `accumulator` object. If `accumulator` is not
  14673. * provided, a new object with the same `[[Prototype]]` will be used. The
  14674. * iteratee is invoked with four arguments: (accumulator, value, key, object).
  14675. * Iteratee functions may exit iteration early by explicitly returning `false`.
  14676. *
  14677. * @static
  14678. * @memberOf _
  14679. * @since 1.3.0
  14680. * @category Object
  14681. * @param {Object} object The object to iterate over.
  14682. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  14683. * @param {*} [accumulator] The custom accumulator value.
  14684. * @returns {*} Returns the accumulated value.
  14685. * @example
  14686. *
  14687. * _.transform([2, 3, 4], function(result, n) {
  14688. * result.push(n *= n);
  14689. * return n % 2 == 0;
  14690. * }, []);
  14691. * // => [4, 9]
  14692. *
  14693. * _.transform({ 'a': 1, 'b': 2, 'c': 1 }, function(result, value, key) {
  14694. * (result[value] || (result[value] = [])).push(key);
  14695. * }, {});
  14696. * // => { '1': ['a', 'c'], '2': ['b'] }
  14697. */
  14698. function transform(object, iteratee, accumulator) {
  14699. var isArr = isArray(object),
  14700. isArrLike = isArr || isBuffer(object) || isTypedArray(object);
  14701. iteratee = getIteratee(iteratee, 4);
  14702. if (accumulator == null) {
  14703. var Ctor = object && object.constructor;
  14704. if (isArrLike) {
  14705. accumulator = isArr ? new Ctor : [];
  14706. }
  14707. else if (isObject(object)) {
  14708. accumulator = isFunction(Ctor) ? baseCreate(getPrototype(object)) : {};
  14709. }
  14710. else {
  14711. accumulator = {};
  14712. }
  14713. }
  14714. (isArrLike ? arrayEach : baseForOwn)(object, function(value, index, object) {
  14715. return iteratee(accumulator, value, index, object);
  14716. });
  14717. return accumulator;
  14718. }
  14719. /**
  14720. * Removes the property at `path` of `object`.
  14721. *
  14722. * **Note:** This method mutates `object`.
  14723. *
  14724. * @static
  14725. * @memberOf _
  14726. * @since 4.0.0
  14727. * @category Object
  14728. * @param {Object} object The object to modify.
  14729. * @param {Array|string} path The path of the property to unset.
  14730. * @returns {boolean} Returns `true` if the property is deleted, else `false`.
  14731. * @example
  14732. *
  14733. * var object = { 'a': [{ 'b': { 'c': 7 } }] };
  14734. * _.unset(object, 'a[0].b.c');
  14735. * // => true
  14736. *
  14737. * console.log(object);
  14738. * // => { 'a': [{ 'b': {} }] };
  14739. *
  14740. * _.unset(object, ['a', '0', 'b', 'c']);
  14741. * // => true
  14742. *
  14743. * console.log(object);
  14744. * // => { 'a': [{ 'b': {} }] };
  14745. */
  14746. function unset(object, path) {
  14747. return object == null ? true : baseUnset(object, path);
  14748. }
  14749. /**
  14750. * This method is like `_.set` except that accepts `updater` to produce the
  14751. * value to set. Use `_.updateWith` to customize `path` creation. The `updater`
  14752. * is invoked with one argument: (value).
  14753. *
  14754. * **Note:** This method mutates `object`.
  14755. *
  14756. * @static
  14757. * @memberOf _
  14758. * @since 4.6.0
  14759. * @category Object
  14760. * @param {Object} object The object to modify.
  14761. * @param {Array|string} path The path of the property to set.
  14762. * @param {Function} updater The function to produce the updated value.
  14763. * @returns {Object} Returns `object`.
  14764. * @example
  14765. *
  14766. * var object = { 'a': [{ 'b': { 'c': 3 } }] };
  14767. *
  14768. * _.update(object, 'a[0].b.c', function(n) { return n * n; });
  14769. * console.log(object.a[0].b.c);
  14770. * // => 9
  14771. *
  14772. * _.update(object, 'x[0].y.z', function(n) { return n ? n + 1 : 0; });
  14773. * console.log(object.x[0].y.z);
  14774. * // => 0
  14775. */
  14776. function update(object, path, updater) {
  14777. return object == null ? object : baseUpdate(object, path, castFunction(updater));
  14778. }
  14779. /**
  14780. * This method is like `_.update` except that it accepts `customizer` which is
  14781. * invoked to produce the objects of `path`. If `customizer` returns `undefined`
  14782. * path creation is handled by the method instead. The `customizer` is invoked
  14783. * with three arguments: (nsValue, key, nsObject).
  14784. *
  14785. * **Note:** This method mutates `object`.
  14786. *
  14787. * @static
  14788. * @memberOf _
  14789. * @since 4.6.0
  14790. * @category Object
  14791. * @param {Object} object The object to modify.
  14792. * @param {Array|string} path The path of the property to set.
  14793. * @param {Function} updater The function to produce the updated value.
  14794. * @param {Function} [customizer] The function to customize assigned values.
  14795. * @returns {Object} Returns `object`.
  14796. * @example
  14797. *
  14798. * var object = {};
  14799. *
  14800. * _.updateWith(object, '[0][1]', _.constant('a'), Object);
  14801. * // => { '0': { '1': 'a' } }
  14802. */
  14803. function updateWith(object, path, updater, customizer) {
  14804. customizer = typeof customizer == 'function' ? customizer : undefined;
  14805. return object == null ? object : baseUpdate(object, path, castFunction(updater), customizer);
  14806. }
  14807. /**
  14808. * Creates an array of the own enumerable string keyed property values of `object`.
  14809. *
  14810. * **Note:** Non-object values are coerced to objects.
  14811. *
  14812. * @static
  14813. * @since 0.1.0
  14814. * @memberOf _
  14815. * @category Object
  14816. * @param {Object} object The object to query.
  14817. * @returns {Array} Returns the array of property values.
  14818. * @example
  14819. *
  14820. * function Foo() {
  14821. * this.a = 1;
  14822. * this.b = 2;
  14823. * }
  14824. *
  14825. * Foo.prototype.c = 3;
  14826. *
  14827. * _.values(new Foo);
  14828. * // => [1, 2] (iteration order is not guaranteed)
  14829. *
  14830. * _.values('hi');
  14831. * // => ['h', 'i']
  14832. */
  14833. function values(object) {
  14834. return object == null ? [] : baseValues(object, keys(object));
  14835. }
  14836. /**
  14837. * Creates an array of the own and inherited enumerable string keyed property
  14838. * values of `object`.
  14839. *
  14840. * **Note:** Non-object values are coerced to objects.
  14841. *
  14842. * @static
  14843. * @memberOf _
  14844. * @since 3.0.0
  14845. * @category Object
  14846. * @param {Object} object The object to query.
  14847. * @returns {Array} Returns the array of property values.
  14848. * @example
  14849. *
  14850. * function Foo() {
  14851. * this.a = 1;
  14852. * this.b = 2;
  14853. * }
  14854. *
  14855. * Foo.prototype.c = 3;
  14856. *
  14857. * _.valuesIn(new Foo);
  14858. * // => [1, 2, 3] (iteration order is not guaranteed)
  14859. */
  14860. function valuesIn(object) {
  14861. return object == null ? [] : baseValues(object, keysIn(object));
  14862. }
  14863. /*------------------------------------------------------------------------*/
  14864. /**
  14865. * Clamps `number` within the inclusive `lower` and `upper` bounds.
  14866. *
  14867. * @static
  14868. * @memberOf _
  14869. * @since 4.0.0
  14870. * @category Number
  14871. * @param {number} number The number to clamp.
  14872. * @param {number} [lower] The lower bound.
  14873. * @param {number} upper The upper bound.
  14874. * @returns {number} Returns the clamped number.
  14875. * @example
  14876. *
  14877. * _.clamp(-10, -5, 5);
  14878. * // => -5
  14879. *
  14880. * _.clamp(10, -5, 5);
  14881. * // => 5
  14882. */
  14883. function clamp(number, lower, upper) {
  14884. if (upper === undefined) {
  14885. upper = lower;
  14886. lower = undefined;
  14887. }
  14888. if (upper !== undefined) {
  14889. upper = toNumber(upper);
  14890. upper = upper === upper ? upper : 0;
  14891. }
  14892. if (lower !== undefined) {
  14893. lower = toNumber(lower);
  14894. lower = lower === lower ? lower : 0;
  14895. }
  14896. return baseClamp(toNumber(number), lower, upper);
  14897. }
  14898. /**
  14899. * Checks if `n` is between `start` and up to, but not including, `end`. If
  14900. * `end` is not specified, it's set to `start` with `start` then set to `0`.
  14901. * If `start` is greater than `end` the params are swapped to support
  14902. * negative ranges.
  14903. *
  14904. * @static
  14905. * @memberOf _
  14906. * @since 3.3.0
  14907. * @category Number
  14908. * @param {number} number The number to check.
  14909. * @param {number} [start=0] The start of the range.
  14910. * @param {number} end The end of the range.
  14911. * @returns {boolean} Returns `true` if `number` is in the range, else `false`.
  14912. * @see _.range, _.rangeRight
  14913. * @example
  14914. *
  14915. * _.inRange(3, 2, 4);
  14916. * // => true
  14917. *
  14918. * _.inRange(4, 8);
  14919. * // => true
  14920. *
  14921. * _.inRange(4, 2);
  14922. * // => false
  14923. *
  14924. * _.inRange(2, 2);
  14925. * // => false
  14926. *
  14927. * _.inRange(1.2, 2);
  14928. * // => true
  14929. *
  14930. * _.inRange(5.2, 4);
  14931. * // => false
  14932. *
  14933. * _.inRange(-3, -2, -6);
  14934. * // => true
  14935. */
  14936. function inRange(number, start, end) {
  14937. start = toFinite(start);
  14938. if (end === undefined) {
  14939. end = start;
  14940. start = 0;
  14941. } else {
  14942. end = toFinite(end);
  14943. }
  14944. number = toNumber(number);
  14945. return baseInRange(number, start, end);
  14946. }
  14947. /**
  14948. * Produces a random number between the inclusive `lower` and `upper` bounds.
  14949. * If only one argument is provided a number between `0` and the given number
  14950. * is returned. If `floating` is `true`, or either `lower` or `upper` are
  14951. * floats, a floating-point number is returned instead of an integer.
  14952. *
  14953. * **Note:** JavaScript follows the IEEE-754 standard for resolving
  14954. * floating-point values which can produce unexpected results.
  14955. *
  14956. * @static
  14957. * @memberOf _
  14958. * @since 0.7.0
  14959. * @category Number
  14960. * @param {number} [lower=0] The lower bound.
  14961. * @param {number} [upper=1] The upper bound.
  14962. * @param {boolean} [floating] Specify returning a floating-point number.
  14963. * @returns {number} Returns the random number.
  14964. * @example
  14965. *
  14966. * _.random(0, 5);
  14967. * // => an integer between 0 and 5
  14968. *
  14969. * _.random(5);
  14970. * // => also an integer between 0 and 5
  14971. *
  14972. * _.random(5, true);
  14973. * // => a floating-point number between 0 and 5
  14974. *
  14975. * _.random(1.2, 5.2);
  14976. * // => a floating-point number between 1.2 and 5.2
  14977. */
  14978. function random(lower, upper, floating) {
  14979. if (floating && typeof floating != 'boolean' && isIterateeCall(lower, upper, floating)) {
  14980. upper = floating = undefined;
  14981. }
  14982. if (floating === undefined) {
  14983. if (typeof upper == 'boolean') {
  14984. floating = upper;
  14985. upper = undefined;
  14986. }
  14987. else if (typeof lower == 'boolean') {
  14988. floating = lower;
  14989. lower = undefined;
  14990. }
  14991. }
  14992. if (lower === undefined && upper === undefined) {
  14993. lower = 0;
  14994. upper = 1;
  14995. }
  14996. else {
  14997. lower = toFinite(lower);
  14998. if (upper === undefined) {
  14999. upper = lower;
  15000. lower = 0;
  15001. } else {
  15002. upper = toFinite(upper);
  15003. }
  15004. }
  15005. if (lower > upper) {
  15006. var temp = lower;
  15007. lower = upper;
  15008. upper = temp;
  15009. }
  15010. if (floating || lower % 1 || upper % 1) {
  15011. var rand = nativeRandom();
  15012. return nativeMin(lower + (rand * (upper - lower + freeParseFloat('1e-' + ((rand + '').length - 1)))), upper);
  15013. }
  15014. return baseRandom(lower, upper);
  15015. }
  15016. /*------------------------------------------------------------------------*/
  15017. /**
  15018. * Converts `string` to [camel case](https://en.wikipedia.org/wiki/CamelCase).
  15019. *
  15020. * @static
  15021. * @memberOf _
  15022. * @since 3.0.0
  15023. * @category String
  15024. * @param {string} [string=''] The string to convert.
  15025. * @returns {string} Returns the camel cased string.
  15026. * @example
  15027. *
  15028. * _.camelCase('Foo Bar');
  15029. * // => 'fooBar'
  15030. *
  15031. * _.camelCase('--foo-bar--');
  15032. * // => 'fooBar'
  15033. *
  15034. * _.camelCase('__FOO_BAR__');
  15035. * // => 'fooBar'
  15036. */
  15037. var camelCase = createCompounder(function(result, word, index) {
  15038. word = word.toLowerCase();
  15039. return result + (index ? capitalize(word) : word);
  15040. });
  15041. /**
  15042. * Converts the first character of `string` to upper case and the remaining
  15043. * to lower case.
  15044. *
  15045. * @static
  15046. * @memberOf _
  15047. * @since 3.0.0
  15048. * @category String
  15049. * @param {string} [string=''] The string to capitalize.
  15050. * @returns {string} Returns the capitalized string.
  15051. * @example
  15052. *
  15053. * _.capitalize('FRED');
  15054. * // => 'Fred'
  15055. */
  15056. function capitalize(string) {
  15057. return upperFirst(toString(string).toLowerCase());
  15058. }
  15059. /**
  15060. * Deburrs `string` by converting
  15061. * [Latin-1 Supplement](https://en.wikipedia.org/wiki/Latin-1_Supplement_(Unicode_block)#Character_table)
  15062. * and [Latin Extended-A](https://en.wikipedia.org/wiki/Latin_Extended-A)
  15063. * letters to basic Latin letters and removing
  15064. * [combining diacritical marks](https://en.wikipedia.org/wiki/Combining_Diacritical_Marks).
  15065. *
  15066. * @static
  15067. * @memberOf _
  15068. * @since 3.0.0
  15069. * @category String
  15070. * @param {string} [string=''] The string to deburr.
  15071. * @returns {string} Returns the deburred string.
  15072. * @example
  15073. *
  15074. * _.deburr('déjà vu');
  15075. * // => 'deja vu'
  15076. */
  15077. function deburr(string) {
  15078. string = toString(string);
  15079. return string && string.replace(reLatin, deburrLetter).replace(reComboMark, '');
  15080. }
  15081. /**
  15082. * Checks if `string` ends with the given target string.
  15083. *
  15084. * @static
  15085. * @memberOf _
  15086. * @since 3.0.0
  15087. * @category String
  15088. * @param {string} [string=''] The string to inspect.
  15089. * @param {string} [target] The string to search for.
  15090. * @param {number} [position=string.length] The position to search up to.
  15091. * @returns {boolean} Returns `true` if `string` ends with `target`,
  15092. * else `false`.
  15093. * @example
  15094. *
  15095. * _.endsWith('abc', 'c');
  15096. * // => true
  15097. *
  15098. * _.endsWith('abc', 'b');
  15099. * // => false
  15100. *
  15101. * _.endsWith('abc', 'b', 2);
  15102. * // => true
  15103. */
  15104. function endsWith(string, target, position) {
  15105. string = toString(string);
  15106. target = baseToString(target);
  15107. var length = string.length;
  15108. position = position === undefined
  15109. ? length
  15110. : baseClamp(toInteger(position), 0, length);
  15111. var end = position;
  15112. position -= target.length;
  15113. return position >= 0 && string.slice(position, end) == target;
  15114. }
  15115. /**
  15116. * Converts the characters "&", "<", ">", '"', and "'" in `string` to their
  15117. * corresponding HTML entities.
  15118. *
  15119. * **Note:** No other characters are escaped. To escape additional
  15120. * characters use a third-party library like [_he_](https://mths.be/he).
  15121. *
  15122. * Though the ">" character is escaped for symmetry, characters like
  15123. * ">" and "/" don't need escaping in HTML and have no special meaning
  15124. * unless they're part of a tag or unquoted attribute value. See
  15125. * [Mathias Bynens's article](https://mathiasbynens.be/notes/ambiguous-ampersands)
  15126. * (under "semi-related fun fact") for more details.
  15127. *
  15128. * When working with HTML you should always
  15129. * [quote attribute values](http://wonko.com/post/html-escaping) to reduce
  15130. * XSS vectors.
  15131. *
  15132. * @static
  15133. * @since 0.1.0
  15134. * @memberOf _
  15135. * @category String
  15136. * @param {string} [string=''] The string to escape.
  15137. * @returns {string} Returns the escaped string.
  15138. * @example
  15139. *
  15140. * _.escape('fred, barney, & pebbles');
  15141. * // => 'fred, barney, &amp; pebbles'
  15142. */
  15143. function escape(string) {
  15144. string = toString(string);
  15145. return (string && reHasUnescapedHtml.test(string))
  15146. ? string.replace(reUnescapedHtml, escapeHtmlChar)
  15147. : string;
  15148. }
  15149. /**
  15150. * Escapes the `RegExp` special characters "^", "$", "\", ".", "*", "+",
  15151. * "?", "(", ")", "[", "]", "{", "}", and "|" in `string`.
  15152. *
  15153. * @static
  15154. * @memberOf _
  15155. * @since 3.0.0
  15156. * @category String
  15157. * @param {string} [string=''] The string to escape.
  15158. * @returns {string} Returns the escaped string.
  15159. * @example
  15160. *
  15161. * _.escapeRegExp('[lodash](https://lodash.com/)');
  15162. * // => '\[lodash\]\(https://lodash\.com/\)'
  15163. */
  15164. function escapeRegExp(string) {
  15165. string = toString(string);
  15166. return (string && reHasRegExpChar.test(string))
  15167. ? string.replace(reRegExpChar, '\\$&')
  15168. : string;
  15169. }
  15170. /**
  15171. * Converts `string` to
  15172. * [kebab case](https://en.wikipedia.org/wiki/Letter_case#Special_case_styles).
  15173. *
  15174. * @static
  15175. * @memberOf _
  15176. * @since 3.0.0
  15177. * @category String
  15178. * @param {string} [string=''] The string to convert.
  15179. * @returns {string} Returns the kebab cased string.
  15180. * @example
  15181. *
  15182. * _.kebabCase('Foo Bar');
  15183. * // => 'foo-bar'
  15184. *
  15185. * _.kebabCase('fooBar');
  15186. * // => 'foo-bar'
  15187. *
  15188. * _.kebabCase('__FOO_BAR__');
  15189. * // => 'foo-bar'
  15190. */
  15191. var kebabCase = createCompounder(function(result, word, index) {
  15192. return result + (index ? '-' : '') + word.toLowerCase();
  15193. });
  15194. /**
  15195. * Converts `string`, as space separated words, to lower case.
  15196. *
  15197. * @static
  15198. * @memberOf _
  15199. * @since 4.0.0
  15200. * @category String
  15201. * @param {string} [string=''] The string to convert.
  15202. * @returns {string} Returns the lower cased string.
  15203. * @example
  15204. *
  15205. * _.lowerCase('--Foo-Bar--');
  15206. * // => 'foo bar'
  15207. *
  15208. * _.lowerCase('fooBar');
  15209. * // => 'foo bar'
  15210. *
  15211. * _.lowerCase('__FOO_BAR__');
  15212. * // => 'foo bar'
  15213. */
  15214. var lowerCase = createCompounder(function(result, word, index) {
  15215. return result + (index ? ' ' : '') + word.toLowerCase();
  15216. });
  15217. /**
  15218. * Converts the first character of `string` to lower case.
  15219. *
  15220. * @static
  15221. * @memberOf _
  15222. * @since 4.0.0
  15223. * @category String
  15224. * @param {string} [string=''] The string to convert.
  15225. * @returns {string} Returns the converted string.
  15226. * @example
  15227. *
  15228. * _.lowerFirst('Fred');
  15229. * // => 'fred'
  15230. *
  15231. * _.lowerFirst('FRED');
  15232. * // => 'fRED'
  15233. */
  15234. var lowerFirst = createCaseFirst('toLowerCase');
  15235. /**
  15236. * Pads `string` on the left and right sides if it's shorter than `length`.
  15237. * Padding characters are truncated if they can't be evenly divided by `length`.
  15238. *
  15239. * @static
  15240. * @memberOf _
  15241. * @since 3.0.0
  15242. * @category String
  15243. * @param {string} [string=''] The string to pad.
  15244. * @param {number} [length=0] The padding length.
  15245. * @param {string} [chars=' '] The string used as padding.
  15246. * @returns {string} Returns the padded string.
  15247. * @example
  15248. *
  15249. * _.pad('abc', 8);
  15250. * // => ' abc '
  15251. *
  15252. * _.pad('abc', 8, '_-');
  15253. * // => '_-abc_-_'
  15254. *
  15255. * _.pad('abc', 3);
  15256. * // => 'abc'
  15257. */
  15258. function pad(string, length, chars) {
  15259. string = toString(string);
  15260. length = toInteger(length);
  15261. var strLength = length ? stringSize(string) : 0;
  15262. if (!length || strLength >= length) {
  15263. return string;
  15264. }
  15265. var mid = (length - strLength) / 2;
  15266. return (
  15267. createPadding(nativeFloor(mid), chars) +
  15268. string +
  15269. createPadding(nativeCeil(mid), chars)
  15270. );
  15271. }
  15272. /**
  15273. * Pads `string` on the right side if it's shorter than `length`. Padding
  15274. * characters are truncated if they exceed `length`.
  15275. *
  15276. * @static
  15277. * @memberOf _
  15278. * @since 4.0.0
  15279. * @category String
  15280. * @param {string} [string=''] The string to pad.
  15281. * @param {number} [length=0] The padding length.
  15282. * @param {string} [chars=' '] The string used as padding.
  15283. * @returns {string} Returns the padded string.
  15284. * @example
  15285. *
  15286. * _.padEnd('abc', 6);
  15287. * // => 'abc '
  15288. *
  15289. * _.padEnd('abc', 6, '_-');
  15290. * // => 'abc_-_'
  15291. *
  15292. * _.padEnd('abc', 3);
  15293. * // => 'abc'
  15294. */
  15295. function padEnd(string, length, chars) {
  15296. string = toString(string);
  15297. length = toInteger(length);
  15298. var strLength = length ? stringSize(string) : 0;
  15299. return (length && strLength < length)
  15300. ? (string + createPadding(length - strLength, chars))
  15301. : string;
  15302. }
  15303. /**
  15304. * Pads `string` on the left side if it's shorter than `length`. Padding
  15305. * characters are truncated if they exceed `length`.
  15306. *
  15307. * @static
  15308. * @memberOf _
  15309. * @since 4.0.0
  15310. * @category String
  15311. * @param {string} [string=''] The string to pad.
  15312. * @param {number} [length=0] The padding length.
  15313. * @param {string} [chars=' '] The string used as padding.
  15314. * @returns {string} Returns the padded string.
  15315. * @example
  15316. *
  15317. * _.padStart('abc', 6);
  15318. * // => ' abc'
  15319. *
  15320. * _.padStart('abc', 6, '_-');
  15321. * // => '_-_abc'
  15322. *
  15323. * _.padStart('abc', 3);
  15324. * // => 'abc'
  15325. */
  15326. function padStart(string, length, chars) {
  15327. string = toString(string);
  15328. length = toInteger(length);
  15329. var strLength = length ? stringSize(string) : 0;
  15330. return (length && strLength < length)
  15331. ? (createPadding(length - strLength, chars) + string)
  15332. : string;
  15333. }
  15334. /**
  15335. * Converts `string` to an integer of the specified radix. If `radix` is
  15336. * `undefined` or `0`, a `radix` of `10` is used unless `value` is a
  15337. * hexadecimal, in which case a `radix` of `16` is used.
  15338. *
  15339. * **Note:** This method aligns with the
  15340. * [ES5 implementation](https://es5.github.io/#x15.1.2.2) of `parseInt`.
  15341. *
  15342. * @static
  15343. * @memberOf _
  15344. * @since 1.1.0
  15345. * @category String
  15346. * @param {string} string The string to convert.
  15347. * @param {number} [radix=10] The radix to interpret `value` by.
  15348. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  15349. * @returns {number} Returns the converted integer.
  15350. * @example
  15351. *
  15352. * _.parseInt('08');
  15353. * // => 8
  15354. *
  15355. * _.map(['6', '08', '10'], _.parseInt);
  15356. * // => [6, 8, 10]
  15357. */
  15358. function parseInt(string, radix, guard) {
  15359. if (guard || radix == null) {
  15360. radix = 0;
  15361. } else if (radix) {
  15362. radix = +radix;
  15363. }
  15364. return nativeParseInt(toString(string).replace(reTrimStart, ''), radix || 0);
  15365. }
  15366. /**
  15367. * Repeats the given string `n` times.
  15368. *
  15369. * @static
  15370. * @memberOf _
  15371. * @since 3.0.0
  15372. * @category String
  15373. * @param {string} [string=''] The string to repeat.
  15374. * @param {number} [n=1] The number of times to repeat the string.
  15375. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  15376. * @returns {string} Returns the repeated string.
  15377. * @example
  15378. *
  15379. * _.repeat('*', 3);
  15380. * // => '***'
  15381. *
  15382. * _.repeat('abc', 2);
  15383. * // => 'abcabc'
  15384. *
  15385. * _.repeat('abc', 0);
  15386. * // => ''
  15387. */
  15388. function repeat(string, n, guard) {
  15389. if ((guard ? isIterateeCall(string, n, guard) : n === undefined)) {
  15390. n = 1;
  15391. } else {
  15392. n = toInteger(n);
  15393. }
  15394. return baseRepeat(toString(string), n);
  15395. }
  15396. /**
  15397. * Replaces matches for `pattern` in `string` with `replacement`.
  15398. *
  15399. * **Note:** This method is based on
  15400. * [`String#replace`](https://mdn.io/String/replace).
  15401. *
  15402. * @static
  15403. * @memberOf _
  15404. * @since 4.0.0
  15405. * @category String
  15406. * @param {string} [string=''] The string to modify.
  15407. * @param {RegExp|string} pattern The pattern to replace.
  15408. * @param {Function|string} replacement The match replacement.
  15409. * @returns {string} Returns the modified string.
  15410. * @example
  15411. *
  15412. * _.replace('Hi Fred', 'Fred', 'Barney');
  15413. * // => 'Hi Barney'
  15414. */
  15415. function replace() {
  15416. var args = arguments,
  15417. string = toString(args[0]);
  15418. return args.length < 3 ? string : string.replace(args[1], args[2]);
  15419. }
  15420. /**
  15421. * Converts `string` to
  15422. * [snake case](https://en.wikipedia.org/wiki/Snake_case).
  15423. *
  15424. * @static
  15425. * @memberOf _
  15426. * @since 3.0.0
  15427. * @category String
  15428. * @param {string} [string=''] The string to convert.
  15429. * @returns {string} Returns the snake cased string.
  15430. * @example
  15431. *
  15432. * _.snakeCase('Foo Bar');
  15433. * // => 'foo_bar'
  15434. *
  15435. * _.snakeCase('fooBar');
  15436. * // => 'foo_bar'
  15437. *
  15438. * _.snakeCase('--FOO-BAR--');
  15439. * // => 'foo_bar'
  15440. */
  15441. var snakeCase = createCompounder(function(result, word, index) {
  15442. return result + (index ? '_' : '') + word.toLowerCase();
  15443. });
  15444. /**
  15445. * Splits `string` by `separator`.
  15446. *
  15447. * **Note:** This method is based on
  15448. * [`String#split`](https://mdn.io/String/split).
  15449. *
  15450. * @static
  15451. * @memberOf _
  15452. * @since 4.0.0
  15453. * @category String
  15454. * @param {string} [string=''] The string to split.
  15455. * @param {RegExp|string} separator The separator pattern to split by.
  15456. * @param {number} [limit] The length to truncate results to.
  15457. * @returns {Array} Returns the string segments.
  15458. * @example
  15459. *
  15460. * _.split('a-b-c', '-', 2);
  15461. * // => ['a', 'b']
  15462. */
  15463. function split(string, separator, limit) {
  15464. if (limit && typeof limit != 'number' && isIterateeCall(string, separator, limit)) {
  15465. separator = limit = undefined;
  15466. }
  15467. limit = limit === undefined ? MAX_ARRAY_LENGTH : limit >>> 0;
  15468. if (!limit) {
  15469. return [];
  15470. }
  15471. string = toString(string);
  15472. if (string && (
  15473. typeof separator == 'string' ||
  15474. (separator != null && !isRegExp(separator))
  15475. )) {
  15476. separator = baseToString(separator);
  15477. if (!separator && hasUnicode(string)) {
  15478. return castSlice(stringToArray(string), 0, limit);
  15479. }
  15480. }
  15481. return string.split(separator, limit);
  15482. }
  15483. /**
  15484. * Converts `string` to
  15485. * [start case](https://en.wikipedia.org/wiki/Letter_case#Stylistic_or_specialised_usage).
  15486. *
  15487. * @static
  15488. * @memberOf _
  15489. * @since 3.1.0
  15490. * @category String
  15491. * @param {string} [string=''] The string to convert.
  15492. * @returns {string} Returns the start cased string.
  15493. * @example
  15494. *
  15495. * _.startCase('--foo-bar--');
  15496. * // => 'Foo Bar'
  15497. *
  15498. * _.startCase('fooBar');
  15499. * // => 'Foo Bar'
  15500. *
  15501. * _.startCase('__FOO_BAR__');
  15502. * // => 'FOO BAR'
  15503. */
  15504. var startCase = createCompounder(function(result, word, index) {
  15505. return result + (index ? ' ' : '') + upperFirst(word);
  15506. });
  15507. /**
  15508. * Checks if `string` starts with the given target string.
  15509. *
  15510. * @static
  15511. * @memberOf _
  15512. * @since 3.0.0
  15513. * @category String
  15514. * @param {string} [string=''] The string to inspect.
  15515. * @param {string} [target] The string to search for.
  15516. * @param {number} [position=0] The position to search from.
  15517. * @returns {boolean} Returns `true` if `string` starts with `target`,
  15518. * else `false`.
  15519. * @example
  15520. *
  15521. * _.startsWith('abc', 'a');
  15522. * // => true
  15523. *
  15524. * _.startsWith('abc', 'b');
  15525. * // => false
  15526. *
  15527. * _.startsWith('abc', 'b', 1);
  15528. * // => true
  15529. */
  15530. function startsWith(string, target, position) {
  15531. string = toString(string);
  15532. position = position == null
  15533. ? 0
  15534. : baseClamp(toInteger(position), 0, string.length);
  15535. target = baseToString(target);
  15536. return string.slice(position, position + target.length) == target;
  15537. }
  15538. /**
  15539. * Creates a compiled template function that can interpolate data properties
  15540. * in "interpolate" delimiters, HTML-escape interpolated data properties in
  15541. * "escape" delimiters, and execute JavaScript in "evaluate" delimiters. Data
  15542. * properties may be accessed as free variables in the template. If a setting
  15543. * object is given, it takes precedence over `_.templateSettings` values.
  15544. *
  15545. * **Note:** In the development build `_.template` utilizes
  15546. * [sourceURLs](http://www.html5rocks.com/en/tutorials/developertools/sourcemaps/#toc-sourceurl)
  15547. * for easier debugging.
  15548. *
  15549. * For more information on precompiling templates see
  15550. * [lodash's custom builds documentation](https://lodash.com/custom-builds).
  15551. *
  15552. * For more information on Chrome extension sandboxes see
  15553. * [Chrome's extensions documentation](https://developer.chrome.com/extensions/sandboxingEval).
  15554. *
  15555. * @static
  15556. * @since 0.1.0
  15557. * @memberOf _
  15558. * @category String
  15559. * @param {string} [string=''] The template string.
  15560. * @param {Object} [options={}] The options object.
  15561. * @param {RegExp} [options.escape=_.templateSettings.escape]
  15562. * The HTML "escape" delimiter.
  15563. * @param {RegExp} [options.evaluate=_.templateSettings.evaluate]
  15564. * The "evaluate" delimiter.
  15565. * @param {Object} [options.imports=_.templateSettings.imports]
  15566. * An object to import into the template as free variables.
  15567. * @param {RegExp} [options.interpolate=_.templateSettings.interpolate]
  15568. * The "interpolate" delimiter.
  15569. * @param {string} [options.sourceURL='lodash.templateSources[n]']
  15570. * The sourceURL of the compiled template.
  15571. * @param {string} [options.variable='obj']
  15572. * The data object variable name.
  15573. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  15574. * @returns {Function} Returns the compiled template function.
  15575. * @example
  15576. *
  15577. * // Use the "interpolate" delimiter to create a compiled template.
  15578. * var compiled = _.template('hello <%= user %>!');
  15579. * compiled({ 'user': 'fred' });
  15580. * // => 'hello fred!'
  15581. *
  15582. * // Use the HTML "escape" delimiter to escape data property values.
  15583. * var compiled = _.template('<b><%- value %></b>');
  15584. * compiled({ 'value': '<script>' });
  15585. * // => '<b>&lt;script&gt;</b>'
  15586. *
  15587. * // Use the "evaluate" delimiter to execute JavaScript and generate HTML.
  15588. * var compiled = _.template('<% _.forEach(users, function(user) { %><li><%- user %></li><% }); %>');
  15589. * compiled({ 'users': ['fred', 'barney'] });
  15590. * // => '<li>fred</li><li>barney</li>'
  15591. *
  15592. * // Use the internal `print` function in "evaluate" delimiters.
  15593. * var compiled = _.template('<% print("hello " + user); %>!');
  15594. * compiled({ 'user': 'barney' });
  15595. * // => 'hello barney!'
  15596. *
  15597. * // Use the ES template literal delimiter as an "interpolate" delimiter.
  15598. * // Disable support by replacing the "interpolate" delimiter.
  15599. * var compiled = _.template('hello ${ user }!');
  15600. * compiled({ 'user': 'pebbles' });
  15601. * // => 'hello pebbles!'
  15602. *
  15603. * // Use backslashes to treat delimiters as plain text.
  15604. * var compiled = _.template('<%= "\\<%- value %\\>" %>');
  15605. * compiled({ 'value': 'ignored' });
  15606. * // => '<%- value %>'
  15607. *
  15608. * // Use the `imports` option to import `jQuery` as `jq`.
  15609. * var text = '<% jq.each(users, function(user) { %><li><%- user %></li><% }); %>';
  15610. * var compiled = _.template(text, { 'imports': { 'jq': jQuery } });
  15611. * compiled({ 'users': ['fred', 'barney'] });
  15612. * // => '<li>fred</li><li>barney</li>'
  15613. *
  15614. * // Use the `sourceURL` option to specify a custom sourceURL for the template.
  15615. * var compiled = _.template('hello <%= user %>!', { 'sourceURL': '/basic/greeting.jst' });
  15616. * compiled(data);
  15617. * // => Find the source of "greeting.jst" under the Sources tab or Resources panel of the web inspector.
  15618. *
  15619. * // Use the `variable` option to ensure a with-statement isn't used in the compiled template.
  15620. * var compiled = _.template('hi <%= data.user %>!', { 'variable': 'data' });
  15621. * compiled.source;
  15622. * // => function(data) {
  15623. * // var __t, __p = '';
  15624. * // __p += 'hi ' + ((__t = ( data.user )) == null ? '' : __t) + '!';
  15625. * // return __p;
  15626. * // }
  15627. *
  15628. * // Use custom template delimiters.
  15629. * _.templateSettings.interpolate = /{{([\s\S]+?)}}/g;
  15630. * var compiled = _.template('hello {{ user }}!');
  15631. * compiled({ 'user': 'mustache' });
  15632. * // => 'hello mustache!'
  15633. *
  15634. * // Use the `source` property to inline compiled templates for meaningful
  15635. * // line numbers in error messages and stack traces.
  15636. * fs.writeFileSync(path.join(process.cwd(), 'jst.js'), '\
  15637. * var JST = {\
  15638. * "main": ' + _.template(mainText).source + '\
  15639. * };\
  15640. * ');
  15641. */
  15642. function template(string, options, guard) {
  15643. // Based on John Resig's `tmpl` implementation
  15644. // (http://ejohn.org/blog/javascript-micro-templating/)
  15645. // and Laura Doktorova's doT.js (https://github.com/olado/doT).
  15646. var settings = lodash.templateSettings;
  15647. if (guard && isIterateeCall(string, options, guard)) {
  15648. options = undefined;
  15649. }
  15650. string = toString(string);
  15651. options = assignInWith({}, options, settings, customDefaultsAssignIn);
  15652. var imports = assignInWith({}, options.imports, settings.imports, customDefaultsAssignIn),
  15653. importsKeys = keys(imports),
  15654. importsValues = baseValues(imports, importsKeys);
  15655. var isEscaping,
  15656. isEvaluating,
  15657. index = 0,
  15658. interpolate = options.interpolate || reNoMatch,
  15659. source = "__p += '";
  15660. // Compile the regexp to match each delimiter.
  15661. var reDelimiters = RegExp(
  15662. (options.escape || reNoMatch).source + '|' +
  15663. interpolate.source + '|' +
  15664. (interpolate === reInterpolate ? reEsTemplate : reNoMatch).source + '|' +
  15665. (options.evaluate || reNoMatch).source + '|$'
  15666. , 'g');
  15667. // Use a sourceURL for easier debugging.
  15668. // The sourceURL gets injected into the source that's eval-ed, so be careful
  15669. // to normalize all kinds of whitespace, so e.g. newlines (and unicode versions of it) can't sneak in
  15670. // and escape the comment, thus injecting code that gets evaled.
  15671. var sourceURL = '//# sourceURL=' +
  15672. (hasOwnProperty.call(options, 'sourceURL')
  15673. ? (options.sourceURL + '').replace(/\s/g, ' ')
  15674. : ('lodash.templateSources[' + (++templateCounter) + ']')
  15675. ) + '\n';
  15676. string.replace(reDelimiters, function(match, escapeValue, interpolateValue, esTemplateValue, evaluateValue, offset) {
  15677. interpolateValue || (interpolateValue = esTemplateValue);
  15678. // Escape characters that can't be included in string literals.
  15679. source += string.slice(index, offset).replace(reUnescapedString, escapeStringChar);
  15680. // Replace delimiters with snippets.
  15681. if (escapeValue) {
  15682. isEscaping = true;
  15683. source += "' +\n__e(" + escapeValue + ") +\n'";
  15684. }
  15685. if (evaluateValue) {
  15686. isEvaluating = true;
  15687. source += "';\n" + evaluateValue + ";\n__p += '";
  15688. }
  15689. if (interpolateValue) {
  15690. source += "' +\n((__t = (" + interpolateValue + ")) == null ? '' : __t) +\n'";
  15691. }
  15692. index = offset + match.length;
  15693. // The JS engine embedded in Adobe products needs `match` returned in
  15694. // order to produce the correct `offset` value.
  15695. return match;
  15696. });
  15697. source += "';\n";
  15698. // If `variable` is not specified wrap a with-statement around the generated
  15699. // code to add the data object to the top of the scope chain.
  15700. var variable = hasOwnProperty.call(options, 'variable') && options.variable;
  15701. if (!variable) {
  15702. source = 'with (obj) {\n' + source + '\n}\n';
  15703. }
  15704. // Throw an error if a forbidden character was found in `variable`, to prevent
  15705. // potential command injection attacks.
  15706. else if (reForbiddenIdentifierChars.test(variable)) {
  15707. throw new Error(INVALID_TEMPL_VAR_ERROR_TEXT);
  15708. }
  15709. // Cleanup code by stripping empty strings.
  15710. source = (isEvaluating ? source.replace(reEmptyStringLeading, '') : source)
  15711. .replace(reEmptyStringMiddle, '$1')
  15712. .replace(reEmptyStringTrailing, '$1;');
  15713. // Frame code as the function body.
  15714. source = 'function(' + (variable || 'obj') + ') {\n' +
  15715. (variable
  15716. ? ''
  15717. : 'obj || (obj = {});\n'
  15718. ) +
  15719. "var __t, __p = ''" +
  15720. (isEscaping
  15721. ? ', __e = _.escape'
  15722. : ''
  15723. ) +
  15724. (isEvaluating
  15725. ? ', __j = Array.prototype.join;\n' +
  15726. "function print() { __p += __j.call(arguments, '') }\n"
  15727. : ';\n'
  15728. ) +
  15729. source +
  15730. 'return __p\n}';
  15731. var result = attempt(function() {
  15732. return Function(importsKeys, sourceURL + 'return ' + source)
  15733. .apply(undefined, importsValues);
  15734. });
  15735. // Provide the compiled function's source by its `toString` method or
  15736. // the `source` property as a convenience for inlining compiled templates.
  15737. result.source = source;
  15738. if (isError(result)) {
  15739. throw result;
  15740. }
  15741. return result;
  15742. }
  15743. /**
  15744. * Converts `string`, as a whole, to lower case just like
  15745. * [String#toLowerCase](https://mdn.io/toLowerCase).
  15746. *
  15747. * @static
  15748. * @memberOf _
  15749. * @since 4.0.0
  15750. * @category String
  15751. * @param {string} [string=''] The string to convert.
  15752. * @returns {string} Returns the lower cased string.
  15753. * @example
  15754. *
  15755. * _.toLower('--Foo-Bar--');
  15756. * // => '--foo-bar--'
  15757. *
  15758. * _.toLower('fooBar');
  15759. * // => 'foobar'
  15760. *
  15761. * _.toLower('__FOO_BAR__');
  15762. * // => '__foo_bar__'
  15763. */
  15764. function toLower(value) {
  15765. return toString(value).toLowerCase();
  15766. }
  15767. /**
  15768. * Converts `string`, as a whole, to upper case just like
  15769. * [String#toUpperCase](https://mdn.io/toUpperCase).
  15770. *
  15771. * @static
  15772. * @memberOf _
  15773. * @since 4.0.0
  15774. * @category String
  15775. * @param {string} [string=''] The string to convert.
  15776. * @returns {string} Returns the upper cased string.
  15777. * @example
  15778. *
  15779. * _.toUpper('--foo-bar--');
  15780. * // => '--FOO-BAR--'
  15781. *
  15782. * _.toUpper('fooBar');
  15783. * // => 'FOOBAR'
  15784. *
  15785. * _.toUpper('__foo_bar__');
  15786. * // => '__FOO_BAR__'
  15787. */
  15788. function toUpper(value) {
  15789. return toString(value).toUpperCase();
  15790. }
  15791. /**
  15792. * Removes leading and trailing whitespace or specified characters from `string`.
  15793. *
  15794. * @static
  15795. * @memberOf _
  15796. * @since 3.0.0
  15797. * @category String
  15798. * @param {string} [string=''] The string to trim.
  15799. * @param {string} [chars=whitespace] The characters to trim.
  15800. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  15801. * @returns {string} Returns the trimmed string.
  15802. * @example
  15803. *
  15804. * _.trim(' abc ');
  15805. * // => 'abc'
  15806. *
  15807. * _.trim('-_-abc-_-', '_-');
  15808. * // => 'abc'
  15809. *
  15810. * _.map([' foo ', ' bar '], _.trim);
  15811. * // => ['foo', 'bar']
  15812. */
  15813. function trim(string, chars, guard) {
  15814. string = toString(string);
  15815. if (string && (guard || chars === undefined)) {
  15816. return baseTrim(string);
  15817. }
  15818. if (!string || !(chars = baseToString(chars))) {
  15819. return string;
  15820. }
  15821. var strSymbols = stringToArray(string),
  15822. chrSymbols = stringToArray(chars),
  15823. start = charsStartIndex(strSymbols, chrSymbols),
  15824. end = charsEndIndex(strSymbols, chrSymbols) + 1;
  15825. return castSlice(strSymbols, start, end).join('');
  15826. }
  15827. /**
  15828. * Removes trailing whitespace or specified characters from `string`.
  15829. *
  15830. * @static
  15831. * @memberOf _
  15832. * @since 4.0.0
  15833. * @category String
  15834. * @param {string} [string=''] The string to trim.
  15835. * @param {string} [chars=whitespace] The characters to trim.
  15836. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  15837. * @returns {string} Returns the trimmed string.
  15838. * @example
  15839. *
  15840. * _.trimEnd(' abc ');
  15841. * // => ' abc'
  15842. *
  15843. * _.trimEnd('-_-abc-_-', '_-');
  15844. * // => '-_-abc'
  15845. */
  15846. function trimEnd(string, chars, guard) {
  15847. string = toString(string);
  15848. if (string && (guard || chars === undefined)) {
  15849. return string.slice(0, trimmedEndIndex(string) + 1);
  15850. }
  15851. if (!string || !(chars = baseToString(chars))) {
  15852. return string;
  15853. }
  15854. var strSymbols = stringToArray(string),
  15855. end = charsEndIndex(strSymbols, stringToArray(chars)) + 1;
  15856. return castSlice(strSymbols, 0, end).join('');
  15857. }
  15858. /**
  15859. * Removes leading whitespace or specified characters from `string`.
  15860. *
  15861. * @static
  15862. * @memberOf _
  15863. * @since 4.0.0
  15864. * @category String
  15865. * @param {string} [string=''] The string to trim.
  15866. * @param {string} [chars=whitespace] The characters to trim.
  15867. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  15868. * @returns {string} Returns the trimmed string.
  15869. * @example
  15870. *
  15871. * _.trimStart(' abc ');
  15872. * // => 'abc '
  15873. *
  15874. * _.trimStart('-_-abc-_-', '_-');
  15875. * // => 'abc-_-'
  15876. */
  15877. function trimStart(string, chars, guard) {
  15878. string = toString(string);
  15879. if (string && (guard || chars === undefined)) {
  15880. return string.replace(reTrimStart, '');
  15881. }
  15882. if (!string || !(chars = baseToString(chars))) {
  15883. return string;
  15884. }
  15885. var strSymbols = stringToArray(string),
  15886. start = charsStartIndex(strSymbols, stringToArray(chars));
  15887. return castSlice(strSymbols, start).join('');
  15888. }
  15889. /**
  15890. * Truncates `string` if it's longer than the given maximum string length.
  15891. * The last characters of the truncated string are replaced with the omission
  15892. * string which defaults to "...".
  15893. *
  15894. * @static
  15895. * @memberOf _
  15896. * @since 4.0.0
  15897. * @category String
  15898. * @param {string} [string=''] The string to truncate.
  15899. * @param {Object} [options={}] The options object.
  15900. * @param {number} [options.length=30] The maximum string length.
  15901. * @param {string} [options.omission='...'] The string to indicate text is omitted.
  15902. * @param {RegExp|string} [options.separator] The separator pattern to truncate to.
  15903. * @returns {string} Returns the truncated string.
  15904. * @example
  15905. *
  15906. * _.truncate('hi-diddly-ho there, neighborino');
  15907. * // => 'hi-diddly-ho there, neighbo...'
  15908. *
  15909. * _.truncate('hi-diddly-ho there, neighborino', {
  15910. * 'length': 24,
  15911. * 'separator': ' '
  15912. * });
  15913. * // => 'hi-diddly-ho there,...'
  15914. *
  15915. * _.truncate('hi-diddly-ho there, neighborino', {
  15916. * 'length': 24,
  15917. * 'separator': /,? +/
  15918. * });
  15919. * // => 'hi-diddly-ho there...'
  15920. *
  15921. * _.truncate('hi-diddly-ho there, neighborino', {
  15922. * 'omission': ' [...]'
  15923. * });
  15924. * // => 'hi-diddly-ho there, neig [...]'
  15925. */
  15926. function truncate(string, options) {
  15927. var length = DEFAULT_TRUNC_LENGTH,
  15928. omission = DEFAULT_TRUNC_OMISSION;
  15929. if (isObject(options)) {
  15930. var separator = 'separator' in options ? options.separator : separator;
  15931. length = 'length' in options ? toInteger(options.length) : length;
  15932. omission = 'omission' in options ? baseToString(options.omission) : omission;
  15933. }
  15934. string = toString(string);
  15935. var strLength = string.length;
  15936. if (hasUnicode(string)) {
  15937. var strSymbols = stringToArray(string);
  15938. strLength = strSymbols.length;
  15939. }
  15940. if (length >= strLength) {
  15941. return string;
  15942. }
  15943. var end = length - stringSize(omission);
  15944. if (end < 1) {
  15945. return omission;
  15946. }
  15947. var result = strSymbols
  15948. ? castSlice(strSymbols, 0, end).join('')
  15949. : string.slice(0, end);
  15950. if (separator === undefined) {
  15951. return result + omission;
  15952. }
  15953. if (strSymbols) {
  15954. end += (result.length - end);
  15955. }
  15956. if (isRegExp(separator)) {
  15957. if (string.slice(end).search(separator)) {
  15958. var match,
  15959. substring = result;
  15960. if (!separator.global) {
  15961. separator = RegExp(separator.source, toString(reFlags.exec(separator)) + 'g');
  15962. }
  15963. separator.lastIndex = 0;
  15964. while ((match = separator.exec(substring))) {
  15965. var newEnd = match.index;
  15966. }
  15967. result = result.slice(0, newEnd === undefined ? end : newEnd);
  15968. }
  15969. } else if (string.indexOf(baseToString(separator), end) != end) {
  15970. var index = result.lastIndexOf(separator);
  15971. if (index > -1) {
  15972. result = result.slice(0, index);
  15973. }
  15974. }
  15975. return result + omission;
  15976. }
  15977. /**
  15978. * The inverse of `_.escape`; this method converts the HTML entities
  15979. * `&amp;`, `&lt;`, `&gt;`, `&quot;`, and `&#39;` in `string` to
  15980. * their corresponding characters.
  15981. *
  15982. * **Note:** No other HTML entities are unescaped. To unescape additional
  15983. * HTML entities use a third-party library like [_he_](https://mths.be/he).
  15984. *
  15985. * @static
  15986. * @memberOf _
  15987. * @since 0.6.0
  15988. * @category String
  15989. * @param {string} [string=''] The string to unescape.
  15990. * @returns {string} Returns the unescaped string.
  15991. * @example
  15992. *
  15993. * _.unescape('fred, barney, &amp; pebbles');
  15994. * // => 'fred, barney, & pebbles'
  15995. */
  15996. function unescape(string) {
  15997. string = toString(string);
  15998. return (string && reHasEscapedHtml.test(string))
  15999. ? string.replace(reEscapedHtml, unescapeHtmlChar)
  16000. : string;
  16001. }
  16002. /**
  16003. * Converts `string`, as space separated words, to upper case.
  16004. *
  16005. * @static
  16006. * @memberOf _
  16007. * @since 4.0.0
  16008. * @category String
  16009. * @param {string} [string=''] The string to convert.
  16010. * @returns {string} Returns the upper cased string.
  16011. * @example
  16012. *
  16013. * _.upperCase('--foo-bar');
  16014. * // => 'FOO BAR'
  16015. *
  16016. * _.upperCase('fooBar');
  16017. * // => 'FOO BAR'
  16018. *
  16019. * _.upperCase('__foo_bar__');
  16020. * // => 'FOO BAR'
  16021. */
  16022. var upperCase = createCompounder(function(result, word, index) {
  16023. return result + (index ? ' ' : '') + word.toUpperCase();
  16024. });
  16025. /**
  16026. * Converts the first character of `string` to upper case.
  16027. *
  16028. * @static
  16029. * @memberOf _
  16030. * @since 4.0.0
  16031. * @category String
  16032. * @param {string} [string=''] The string to convert.
  16033. * @returns {string} Returns the converted string.
  16034. * @example
  16035. *
  16036. * _.upperFirst('fred');
  16037. * // => 'Fred'
  16038. *
  16039. * _.upperFirst('FRED');
  16040. * // => 'FRED'
  16041. */
  16042. var upperFirst = createCaseFirst('toUpperCase');
  16043. /**
  16044. * Splits `string` into an array of its words.
  16045. *
  16046. * @static
  16047. * @memberOf _
  16048. * @since 3.0.0
  16049. * @category String
  16050. * @param {string} [string=''] The string to inspect.
  16051. * @param {RegExp|string} [pattern] The pattern to match words.
  16052. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  16053. * @returns {Array} Returns the words of `string`.
  16054. * @example
  16055. *
  16056. * _.words('fred, barney, & pebbles');
  16057. * // => ['fred', 'barney', 'pebbles']
  16058. *
  16059. * _.words('fred, barney, & pebbles', /[^, ]+/g);
  16060. * // => ['fred', 'barney', '&', 'pebbles']
  16061. */
  16062. function words(string, pattern, guard) {
  16063. string = toString(string);
  16064. pattern = guard ? undefined : pattern;
  16065. if (pattern === undefined) {
  16066. return hasUnicodeWord(string) ? unicodeWords(string) : asciiWords(string);
  16067. }
  16068. return string.match(pattern) || [];
  16069. }
  16070. /*------------------------------------------------------------------------*/
  16071. /**
  16072. * Attempts to invoke `func`, returning either the result or the caught error
  16073. * object. Any additional arguments are provided to `func` when it's invoked.
  16074. *
  16075. * @static
  16076. * @memberOf _
  16077. * @since 3.0.0
  16078. * @category Util
  16079. * @param {Function} func The function to attempt.
  16080. * @param {...*} [args] The arguments to invoke `func` with.
  16081. * @returns {*} Returns the `func` result or error object.
  16082. * @example
  16083. *
  16084. * // Avoid throwing errors for invalid selectors.
  16085. * var elements = _.attempt(function(selector) {
  16086. * return document.querySelectorAll(selector);
  16087. * }, '>_>');
  16088. *
  16089. * if (_.isError(elements)) {
  16090. * elements = [];
  16091. * }
  16092. */
  16093. var attempt = baseRest(function(func, args) {
  16094. try {
  16095. return apply(func, undefined, args);
  16096. } catch (e) {
  16097. return isError(e) ? e : new Error(e);
  16098. }
  16099. });
  16100. /**
  16101. * Binds methods of an object to the object itself, overwriting the existing
  16102. * method.
  16103. *
  16104. * **Note:** This method doesn't set the "length" property of bound functions.
  16105. *
  16106. * @static
  16107. * @since 0.1.0
  16108. * @memberOf _
  16109. * @category Util
  16110. * @param {Object} object The object to bind and assign the bound methods to.
  16111. * @param {...(string|string[])} methodNames The object method names to bind.
  16112. * @returns {Object} Returns `object`.
  16113. * @example
  16114. *
  16115. * var view = {
  16116. * 'label': 'docs',
  16117. * 'click': function() {
  16118. * console.log('clicked ' + this.label);
  16119. * }
  16120. * };
  16121. *
  16122. * _.bindAll(view, ['click']);
  16123. * jQuery(element).on('click', view.click);
  16124. * // => Logs 'clicked docs' when clicked.
  16125. */
  16126. var bindAll = flatRest(function(object, methodNames) {
  16127. arrayEach(methodNames, function(key) {
  16128. key = toKey(key);
  16129. baseAssignValue(object, key, bind(object[key], object));
  16130. });
  16131. return object;
  16132. });
  16133. /**
  16134. * Creates a function that iterates over `pairs` and invokes the corresponding
  16135. * function of the first predicate to return truthy. The predicate-function
  16136. * pairs are invoked with the `this` binding and arguments of the created
  16137. * function.
  16138. *
  16139. * @static
  16140. * @memberOf _
  16141. * @since 4.0.0
  16142. * @category Util
  16143. * @param {Array} pairs The predicate-function pairs.
  16144. * @returns {Function} Returns the new composite function.
  16145. * @example
  16146. *
  16147. * var func = _.cond([
  16148. * [_.matches({ 'a': 1 }), _.constant('matches A')],
  16149. * [_.conforms({ 'b': _.isNumber }), _.constant('matches B')],
  16150. * [_.stubTrue, _.constant('no match')]
  16151. * ]);
  16152. *
  16153. * func({ 'a': 1, 'b': 2 });
  16154. * // => 'matches A'
  16155. *
  16156. * func({ 'a': 0, 'b': 1 });
  16157. * // => 'matches B'
  16158. *
  16159. * func({ 'a': '1', 'b': '2' });
  16160. * // => 'no match'
  16161. */
  16162. function cond(pairs) {
  16163. var length = pairs == null ? 0 : pairs.length,
  16164. toIteratee = getIteratee();
  16165. pairs = !length ? [] : arrayMap(pairs, function(pair) {
  16166. if (typeof pair[1] != 'function') {
  16167. throw new TypeError(FUNC_ERROR_TEXT);
  16168. }
  16169. return [toIteratee(pair[0]), pair[1]];
  16170. });
  16171. return baseRest(function(args) {
  16172. var index = -1;
  16173. while (++index < length) {
  16174. var pair = pairs[index];
  16175. if (apply(pair[0], this, args)) {
  16176. return apply(pair[1], this, args);
  16177. }
  16178. }
  16179. });
  16180. }
  16181. /**
  16182. * Creates a function that invokes the predicate properties of `source` with
  16183. * the corresponding property values of a given object, returning `true` if
  16184. * all predicates return truthy, else `false`.
  16185. *
  16186. * **Note:** The created function is equivalent to `_.conformsTo` with
  16187. * `source` partially applied.
  16188. *
  16189. * @static
  16190. * @memberOf _
  16191. * @since 4.0.0
  16192. * @category Util
  16193. * @param {Object} source The object of property predicates to conform to.
  16194. * @returns {Function} Returns the new spec function.
  16195. * @example
  16196. *
  16197. * var objects = [
  16198. * { 'a': 2, 'b': 1 },
  16199. * { 'a': 1, 'b': 2 }
  16200. * ];
  16201. *
  16202. * _.filter(objects, _.conforms({ 'b': function(n) { return n > 1; } }));
  16203. * // => [{ 'a': 1, 'b': 2 }]
  16204. */
  16205. function conforms(source) {
  16206. return baseConforms(baseClone(source, CLONE_DEEP_FLAG));
  16207. }
  16208. /**
  16209. * Creates a function that returns `value`.
  16210. *
  16211. * @static
  16212. * @memberOf _
  16213. * @since 2.4.0
  16214. * @category Util
  16215. * @param {*} value The value to return from the new function.
  16216. * @returns {Function} Returns the new constant function.
  16217. * @example
  16218. *
  16219. * var objects = _.times(2, _.constant({ 'a': 1 }));
  16220. *
  16221. * console.log(objects);
  16222. * // => [{ 'a': 1 }, { 'a': 1 }]
  16223. *
  16224. * console.log(objects[0] === objects[1]);
  16225. * // => true
  16226. */
  16227. function constant(value) {
  16228. return function() {
  16229. return value;
  16230. };
  16231. }
  16232. /**
  16233. * Checks `value` to determine whether a default value should be returned in
  16234. * its place. The `defaultValue` is returned if `value` is `NaN`, `null`,
  16235. * or `undefined`.
  16236. *
  16237. * @static
  16238. * @memberOf _
  16239. * @since 4.14.0
  16240. * @category Util
  16241. * @param {*} value The value to check.
  16242. * @param {*} defaultValue The default value.
  16243. * @returns {*} Returns the resolved value.
  16244. * @example
  16245. *
  16246. * _.defaultTo(1, 10);
  16247. * // => 1
  16248. *
  16249. * _.defaultTo(undefined, 10);
  16250. * // => 10
  16251. */
  16252. function defaultTo(value, defaultValue) {
  16253. return (value == null || value !== value) ? defaultValue : value;
  16254. }
  16255. /**
  16256. * Creates a function that returns the result of invoking the given functions
  16257. * with the `this` binding of the created function, where each successive
  16258. * invocation is supplied the return value of the previous.
  16259. *
  16260. * @static
  16261. * @memberOf _
  16262. * @since 3.0.0
  16263. * @category Util
  16264. * @param {...(Function|Function[])} [funcs] The functions to invoke.
  16265. * @returns {Function} Returns the new composite function.
  16266. * @see _.flowRight
  16267. * @example
  16268. *
  16269. * function square(n) {
  16270. * return n * n;
  16271. * }
  16272. *
  16273. * var addSquare = _.flow([_.add, square]);
  16274. * addSquare(1, 2);
  16275. * // => 9
  16276. */
  16277. var flow = createFlow();
  16278. /**
  16279. * This method is like `_.flow` except that it creates a function that
  16280. * invokes the given functions from right to left.
  16281. *
  16282. * @static
  16283. * @since 3.0.0
  16284. * @memberOf _
  16285. * @category Util
  16286. * @param {...(Function|Function[])} [funcs] The functions to invoke.
  16287. * @returns {Function} Returns the new composite function.
  16288. * @see _.flow
  16289. * @example
  16290. *
  16291. * function square(n) {
  16292. * return n * n;
  16293. * }
  16294. *
  16295. * var addSquare = _.flowRight([square, _.add]);
  16296. * addSquare(1, 2);
  16297. * // => 9
  16298. */
  16299. var flowRight = createFlow(true);
  16300. /**
  16301. * This method returns the first argument it receives.
  16302. *
  16303. * @static
  16304. * @since 0.1.0
  16305. * @memberOf _
  16306. * @category Util
  16307. * @param {*} value Any value.
  16308. * @returns {*} Returns `value`.
  16309. * @example
  16310. *
  16311. * var object = { 'a': 1 };
  16312. *
  16313. * console.log(_.identity(object) === object);
  16314. * // => true
  16315. */
  16316. function identity(value) {
  16317. return value;
  16318. }
  16319. /**
  16320. * Creates a function that invokes `func` with the arguments of the created
  16321. * function. If `func` is a property name, the created function returns the
  16322. * property value for a given element. If `func` is an array or object, the
  16323. * created function returns `true` for elements that contain the equivalent
  16324. * source properties, otherwise it returns `false`.
  16325. *
  16326. * @static
  16327. * @since 4.0.0
  16328. * @memberOf _
  16329. * @category Util
  16330. * @param {*} [func=_.identity] The value to convert to a callback.
  16331. * @returns {Function} Returns the callback.
  16332. * @example
  16333. *
  16334. * var users = [
  16335. * { 'user': 'barney', 'age': 36, 'active': true },
  16336. * { 'user': 'fred', 'age': 40, 'active': false }
  16337. * ];
  16338. *
  16339. * // The `_.matches` iteratee shorthand.
  16340. * _.filter(users, _.iteratee({ 'user': 'barney', 'active': true }));
  16341. * // => [{ 'user': 'barney', 'age': 36, 'active': true }]
  16342. *
  16343. * // The `_.matchesProperty` iteratee shorthand.
  16344. * _.filter(users, _.iteratee(['user', 'fred']));
  16345. * // => [{ 'user': 'fred', 'age': 40 }]
  16346. *
  16347. * // The `_.property` iteratee shorthand.
  16348. * _.map(users, _.iteratee('user'));
  16349. * // => ['barney', 'fred']
  16350. *
  16351. * // Create custom iteratee shorthands.
  16352. * _.iteratee = _.wrap(_.iteratee, function(iteratee, func) {
  16353. * return !_.isRegExp(func) ? iteratee(func) : function(string) {
  16354. * return func.test(string);
  16355. * };
  16356. * });
  16357. *
  16358. * _.filter(['abc', 'def'], /ef/);
  16359. * // => ['def']
  16360. */
  16361. function iteratee(func) {
  16362. return baseIteratee(typeof func == 'function' ? func : baseClone(func, CLONE_DEEP_FLAG));
  16363. }
  16364. /**
  16365. * Creates a function that performs a partial deep comparison between a given
  16366. * object and `source`, returning `true` if the given object has equivalent
  16367. * property values, else `false`.
  16368. *
  16369. * **Note:** The created function is equivalent to `_.isMatch` with `source`
  16370. * partially applied.
  16371. *
  16372. * Partial comparisons will match empty array and empty object `source`
  16373. * values against any array or object value, respectively. See `_.isEqual`
  16374. * for a list of supported value comparisons.
  16375. *
  16376. * **Note:** Multiple values can be checked by combining several matchers
  16377. * using `_.overSome`
  16378. *
  16379. * @static
  16380. * @memberOf _
  16381. * @since 3.0.0
  16382. * @category Util
  16383. * @param {Object} source The object of property values to match.
  16384. * @returns {Function} Returns the new spec function.
  16385. * @example
  16386. *
  16387. * var objects = [
  16388. * { 'a': 1, 'b': 2, 'c': 3 },
  16389. * { 'a': 4, 'b': 5, 'c': 6 }
  16390. * ];
  16391. *
  16392. * _.filter(objects, _.matches({ 'a': 4, 'c': 6 }));
  16393. * // => [{ 'a': 4, 'b': 5, 'c': 6 }]
  16394. *
  16395. * // Checking for several possible values
  16396. * _.filter(objects, _.overSome([_.matches({ 'a': 1 }), _.matches({ 'a': 4 })]));
  16397. * // => [{ 'a': 1, 'b': 2, 'c': 3 }, { 'a': 4, 'b': 5, 'c': 6 }]
  16398. */
  16399. function matches(source) {
  16400. return baseMatches(baseClone(source, CLONE_DEEP_FLAG));
  16401. }
  16402. /**
  16403. * Creates a function that performs a partial deep comparison between the
  16404. * value at `path` of a given object to `srcValue`, returning `true` if the
  16405. * object value is equivalent, else `false`.
  16406. *
  16407. * **Note:** Partial comparisons will match empty array and empty object
  16408. * `srcValue` values against any array or object value, respectively. See
  16409. * `_.isEqual` for a list of supported value comparisons.
  16410. *
  16411. * **Note:** Multiple values can be checked by combining several matchers
  16412. * using `_.overSome`
  16413. *
  16414. * @static
  16415. * @memberOf _
  16416. * @since 3.2.0
  16417. * @category Util
  16418. * @param {Array|string} path The path of the property to get.
  16419. * @param {*} srcValue The value to match.
  16420. * @returns {Function} Returns the new spec function.
  16421. * @example
  16422. *
  16423. * var objects = [
  16424. * { 'a': 1, 'b': 2, 'c': 3 },
  16425. * { 'a': 4, 'b': 5, 'c': 6 }
  16426. * ];
  16427. *
  16428. * _.find(objects, _.matchesProperty('a', 4));
  16429. * // => { 'a': 4, 'b': 5, 'c': 6 }
  16430. *
  16431. * // Checking for several possible values
  16432. * _.filter(objects, _.overSome([_.matchesProperty('a', 1), _.matchesProperty('a', 4)]));
  16433. * // => [{ 'a': 1, 'b': 2, 'c': 3 }, { 'a': 4, 'b': 5, 'c': 6 }]
  16434. */
  16435. function matchesProperty(path, srcValue) {
  16436. return baseMatchesProperty(path, baseClone(srcValue, CLONE_DEEP_FLAG));
  16437. }
  16438. /**
  16439. * Creates a function that invokes the method at `path` of a given object.
  16440. * Any additional arguments are provided to the invoked method.
  16441. *
  16442. * @static
  16443. * @memberOf _
  16444. * @since 3.7.0
  16445. * @category Util
  16446. * @param {Array|string} path The path of the method to invoke.
  16447. * @param {...*} [args] The arguments to invoke the method with.
  16448. * @returns {Function} Returns the new invoker function.
  16449. * @example
  16450. *
  16451. * var objects = [
  16452. * { 'a': { 'b': _.constant(2) } },
  16453. * { 'a': { 'b': _.constant(1) } }
  16454. * ];
  16455. *
  16456. * _.map(objects, _.method('a.b'));
  16457. * // => [2, 1]
  16458. *
  16459. * _.map(objects, _.method(['a', 'b']));
  16460. * // => [2, 1]
  16461. */
  16462. var method = baseRest(function(path, args) {
  16463. return function(object) {
  16464. return baseInvoke(object, path, args);
  16465. };
  16466. });
  16467. /**
  16468. * The opposite of `_.method`; this method creates a function that invokes
  16469. * the method at a given path of `object`. Any additional arguments are
  16470. * provided to the invoked method.
  16471. *
  16472. * @static
  16473. * @memberOf _
  16474. * @since 3.7.0
  16475. * @category Util
  16476. * @param {Object} object The object to query.
  16477. * @param {...*} [args] The arguments to invoke the method with.
  16478. * @returns {Function} Returns the new invoker function.
  16479. * @example
  16480. *
  16481. * var array = _.times(3, _.constant),
  16482. * object = { 'a': array, 'b': array, 'c': array };
  16483. *
  16484. * _.map(['a[2]', 'c[0]'], _.methodOf(object));
  16485. * // => [2, 0]
  16486. *
  16487. * _.map([['a', '2'], ['c', '0']], _.methodOf(object));
  16488. * // => [2, 0]
  16489. */
  16490. var methodOf = baseRest(function(object, args) {
  16491. return function(path) {
  16492. return baseInvoke(object, path, args);
  16493. };
  16494. });
  16495. /**
  16496. * Adds all own enumerable string keyed function properties of a source
  16497. * object to the destination object. If `object` is a function, then methods
  16498. * are added to its prototype as well.
  16499. *
  16500. * **Note:** Use `_.runInContext` to create a pristine `lodash` function to
  16501. * avoid conflicts caused by modifying the original.
  16502. *
  16503. * @static
  16504. * @since 0.1.0
  16505. * @memberOf _
  16506. * @category Util
  16507. * @param {Function|Object} [object=lodash] The destination object.
  16508. * @param {Object} source The object of functions to add.
  16509. * @param {Object} [options={}] The options object.
  16510. * @param {boolean} [options.chain=true] Specify whether mixins are chainable.
  16511. * @returns {Function|Object} Returns `object`.
  16512. * @example
  16513. *
  16514. * function vowels(string) {
  16515. * return _.filter(string, function(v) {
  16516. * return /[aeiou]/i.test(v);
  16517. * });
  16518. * }
  16519. *
  16520. * _.mixin({ 'vowels': vowels });
  16521. * _.vowels('fred');
  16522. * // => ['e']
  16523. *
  16524. * _('fred').vowels().value();
  16525. * // => ['e']
  16526. *
  16527. * _.mixin({ 'vowels': vowels }, { 'chain': false });
  16528. * _('fred').vowels();
  16529. * // => ['e']
  16530. */
  16531. function mixin(object, source, options) {
  16532. var props = keys(source),
  16533. methodNames = baseFunctions(source, props);
  16534. if (options == null &&
  16535. !(isObject(source) && (methodNames.length || !props.length))) {
  16536. options = source;
  16537. source = object;
  16538. object = this;
  16539. methodNames = baseFunctions(source, keys(source));
  16540. }
  16541. var chain = !(isObject(options) && 'chain' in options) || !!options.chain,
  16542. isFunc = isFunction(object);
  16543. arrayEach(methodNames, function(methodName) {
  16544. var func = source[methodName];
  16545. object[methodName] = func;
  16546. if (isFunc) {
  16547. object.prototype[methodName] = function() {
  16548. var chainAll = this.__chain__;
  16549. if (chain || chainAll) {
  16550. var result = object(this.__wrapped__),
  16551. actions = result.__actions__ = copyArray(this.__actions__);
  16552. actions.push({ 'func': func, 'args': arguments, 'thisArg': object });
  16553. result.__chain__ = chainAll;
  16554. return result;
  16555. }
  16556. return func.apply(object, arrayPush([this.value()], arguments));
  16557. };
  16558. }
  16559. });
  16560. return object;
  16561. }
  16562. /**
  16563. * Reverts the `_` variable to its previous value and returns a reference to
  16564. * the `lodash` function.
  16565. *
  16566. * @static
  16567. * @since 0.1.0
  16568. * @memberOf _
  16569. * @category Util
  16570. * @returns {Function} Returns the `lodash` function.
  16571. * @example
  16572. *
  16573. * var lodash = _.noConflict();
  16574. */
  16575. function noConflict() {
  16576. if (root._ === this) {
  16577. root._ = oldDash;
  16578. }
  16579. return this;
  16580. }
  16581. /**
  16582. * This method returns `undefined`.
  16583. *
  16584. * @static
  16585. * @memberOf _
  16586. * @since 2.3.0
  16587. * @category Util
  16588. * @example
  16589. *
  16590. * _.times(2, _.noop);
  16591. * // => [undefined, undefined]
  16592. */
  16593. function noop() {
  16594. // No operation performed.
  16595. }
  16596. /**
  16597. * Creates a function that gets the argument at index `n`. If `n` is negative,
  16598. * the nth argument from the end is returned.
  16599. *
  16600. * @static
  16601. * @memberOf _
  16602. * @since 4.0.0
  16603. * @category Util
  16604. * @param {number} [n=0] The index of the argument to return.
  16605. * @returns {Function} Returns the new pass-thru function.
  16606. * @example
  16607. *
  16608. * var func = _.nthArg(1);
  16609. * func('a', 'b', 'c', 'd');
  16610. * // => 'b'
  16611. *
  16612. * var func = _.nthArg(-2);
  16613. * func('a', 'b', 'c', 'd');
  16614. * // => 'c'
  16615. */
  16616. function nthArg(n) {
  16617. n = toInteger(n);
  16618. return baseRest(function(args) {
  16619. return baseNth(args, n);
  16620. });
  16621. }
  16622. /**
  16623. * Creates a function that invokes `iteratees` with the arguments it receives
  16624. * and returns their results.
  16625. *
  16626. * @static
  16627. * @memberOf _
  16628. * @since 4.0.0
  16629. * @category Util
  16630. * @param {...(Function|Function[])} [iteratees=[_.identity]]
  16631. * The iteratees to invoke.
  16632. * @returns {Function} Returns the new function.
  16633. * @example
  16634. *
  16635. * var func = _.over([Math.max, Math.min]);
  16636. *
  16637. * func(1, 2, 3, 4);
  16638. * // => [4, 1]
  16639. */
  16640. var over = createOver(arrayMap);
  16641. /**
  16642. * Creates a function that checks if **all** of the `predicates` return
  16643. * truthy when invoked with the arguments it receives.
  16644. *
  16645. * Following shorthands are possible for providing predicates.
  16646. * Pass an `Object` and it will be used as an parameter for `_.matches` to create the predicate.
  16647. * Pass an `Array` of parameters for `_.matchesProperty` and the predicate will be created using them.
  16648. *
  16649. * @static
  16650. * @memberOf _
  16651. * @since 4.0.0
  16652. * @category Util
  16653. * @param {...(Function|Function[])} [predicates=[_.identity]]
  16654. * The predicates to check.
  16655. * @returns {Function} Returns the new function.
  16656. * @example
  16657. *
  16658. * var func = _.overEvery([Boolean, isFinite]);
  16659. *
  16660. * func('1');
  16661. * // => true
  16662. *
  16663. * func(null);
  16664. * // => false
  16665. *
  16666. * func(NaN);
  16667. * // => false
  16668. */
  16669. var overEvery = createOver(arrayEvery);
  16670. /**
  16671. * Creates a function that checks if **any** of the `predicates` return
  16672. * truthy when invoked with the arguments it receives.
  16673. *
  16674. * Following shorthands are possible for providing predicates.
  16675. * Pass an `Object` and it will be used as an parameter for `_.matches` to create the predicate.
  16676. * Pass an `Array` of parameters for `_.matchesProperty` and the predicate will be created using them.
  16677. *
  16678. * @static
  16679. * @memberOf _
  16680. * @since 4.0.0
  16681. * @category Util
  16682. * @param {...(Function|Function[])} [predicates=[_.identity]]
  16683. * The predicates to check.
  16684. * @returns {Function} Returns the new function.
  16685. * @example
  16686. *
  16687. * var func = _.overSome([Boolean, isFinite]);
  16688. *
  16689. * func('1');
  16690. * // => true
  16691. *
  16692. * func(null);
  16693. * // => true
  16694. *
  16695. * func(NaN);
  16696. * // => false
  16697. *
  16698. * var matchesFunc = _.overSome([{ 'a': 1 }, { 'a': 2 }])
  16699. * var matchesPropertyFunc = _.overSome([['a', 1], ['a', 2]])
  16700. */
  16701. var overSome = createOver(arraySome);
  16702. /**
  16703. * Creates a function that returns the value at `path` of a given object.
  16704. *
  16705. * @static
  16706. * @memberOf _
  16707. * @since 2.4.0
  16708. * @category Util
  16709. * @param {Array|string} path The path of the property to get.
  16710. * @returns {Function} Returns the new accessor function.
  16711. * @example
  16712. *
  16713. * var objects = [
  16714. * { 'a': { 'b': 2 } },
  16715. * { 'a': { 'b': 1 } }
  16716. * ];
  16717. *
  16718. * _.map(objects, _.property('a.b'));
  16719. * // => [2, 1]
  16720. *
  16721. * _.map(_.sortBy(objects, _.property(['a', 'b'])), 'a.b');
  16722. * // => [1, 2]
  16723. */
  16724. function property(path) {
  16725. return isKey(path) ? baseProperty(toKey(path)) : basePropertyDeep(path);
  16726. }
  16727. /**
  16728. * The opposite of `_.property`; this method creates a function that returns
  16729. * the value at a given path of `object`.
  16730. *
  16731. * @static
  16732. * @memberOf _
  16733. * @since 3.0.0
  16734. * @category Util
  16735. * @param {Object} object The object to query.
  16736. * @returns {Function} Returns the new accessor function.
  16737. * @example
  16738. *
  16739. * var array = [0, 1, 2],
  16740. * object = { 'a': array, 'b': array, 'c': array };
  16741. *
  16742. * _.map(['a[2]', 'c[0]'], _.propertyOf(object));
  16743. * // => [2, 0]
  16744. *
  16745. * _.map([['a', '2'], ['c', '0']], _.propertyOf(object));
  16746. * // => [2, 0]
  16747. */
  16748. function propertyOf(object) {
  16749. return function(path) {
  16750. return object == null ? undefined : baseGet(object, path);
  16751. };
  16752. }
  16753. /**
  16754. * Creates an array of numbers (positive and/or negative) progressing from
  16755. * `start` up to, but not including, `end`. A step of `-1` is used if a negative
  16756. * `start` is specified without an `end` or `step`. If `end` is not specified,
  16757. * it's set to `start` with `start` then set to `0`.
  16758. *
  16759. * **Note:** JavaScript follows the IEEE-754 standard for resolving
  16760. * floating-point values which can produce unexpected results.
  16761. *
  16762. * @static
  16763. * @since 0.1.0
  16764. * @memberOf _
  16765. * @category Util
  16766. * @param {number} [start=0] The start of the range.
  16767. * @param {number} end The end of the range.
  16768. * @param {number} [step=1] The value to increment or decrement by.
  16769. * @returns {Array} Returns the range of numbers.
  16770. * @see _.inRange, _.rangeRight
  16771. * @example
  16772. *
  16773. * _.range(4);
  16774. * // => [0, 1, 2, 3]
  16775. *
  16776. * _.range(-4);
  16777. * // => [0, -1, -2, -3]
  16778. *
  16779. * _.range(1, 5);
  16780. * // => [1, 2, 3, 4]
  16781. *
  16782. * _.range(0, 20, 5);
  16783. * // => [0, 5, 10, 15]
  16784. *
  16785. * _.range(0, -4, -1);
  16786. * // => [0, -1, -2, -3]
  16787. *
  16788. * _.range(1, 4, 0);
  16789. * // => [1, 1, 1]
  16790. *
  16791. * _.range(0);
  16792. * // => []
  16793. */
  16794. var range = createRange();
  16795. /**
  16796. * This method is like `_.range` except that it populates values in
  16797. * descending order.
  16798. *
  16799. * @static
  16800. * @memberOf _
  16801. * @since 4.0.0
  16802. * @category Util
  16803. * @param {number} [start=0] The start of the range.
  16804. * @param {number} end The end of the range.
  16805. * @param {number} [step=1] The value to increment or decrement by.
  16806. * @returns {Array} Returns the range of numbers.
  16807. * @see _.inRange, _.range
  16808. * @example
  16809. *
  16810. * _.rangeRight(4);
  16811. * // => [3, 2, 1, 0]
  16812. *
  16813. * _.rangeRight(-4);
  16814. * // => [-3, -2, -1, 0]
  16815. *
  16816. * _.rangeRight(1, 5);
  16817. * // => [4, 3, 2, 1]
  16818. *
  16819. * _.rangeRight(0, 20, 5);
  16820. * // => [15, 10, 5, 0]
  16821. *
  16822. * _.rangeRight(0, -4, -1);
  16823. * // => [-3, -2, -1, 0]
  16824. *
  16825. * _.rangeRight(1, 4, 0);
  16826. * // => [1, 1, 1]
  16827. *
  16828. * _.rangeRight(0);
  16829. * // => []
  16830. */
  16831. var rangeRight = createRange(true);
  16832. /**
  16833. * This method returns a new empty array.
  16834. *
  16835. * @static
  16836. * @memberOf _
  16837. * @since 4.13.0
  16838. * @category Util
  16839. * @returns {Array} Returns the new empty array.
  16840. * @example
  16841. *
  16842. * var arrays = _.times(2, _.stubArray);
  16843. *
  16844. * console.log(arrays);
  16845. * // => [[], []]
  16846. *
  16847. * console.log(arrays[0] === arrays[1]);
  16848. * // => false
  16849. */
  16850. function stubArray() {
  16851. return [];
  16852. }
  16853. /**
  16854. * This method returns `false`.
  16855. *
  16856. * @static
  16857. * @memberOf _
  16858. * @since 4.13.0
  16859. * @category Util
  16860. * @returns {boolean} Returns `false`.
  16861. * @example
  16862. *
  16863. * _.times(2, _.stubFalse);
  16864. * // => [false, false]
  16865. */
  16866. function stubFalse() {
  16867. return false;
  16868. }
  16869. /**
  16870. * This method returns a new empty object.
  16871. *
  16872. * @static
  16873. * @memberOf _
  16874. * @since 4.13.0
  16875. * @category Util
  16876. * @returns {Object} Returns the new empty object.
  16877. * @example
  16878. *
  16879. * var objects = _.times(2, _.stubObject);
  16880. *
  16881. * console.log(objects);
  16882. * // => [{}, {}]
  16883. *
  16884. * console.log(objects[0] === objects[1]);
  16885. * // => false
  16886. */
  16887. function stubObject() {
  16888. return {};
  16889. }
  16890. /**
  16891. * This method returns an empty string.
  16892. *
  16893. * @static
  16894. * @memberOf _
  16895. * @since 4.13.0
  16896. * @category Util
  16897. * @returns {string} Returns the empty string.
  16898. * @example
  16899. *
  16900. * _.times(2, _.stubString);
  16901. * // => ['', '']
  16902. */
  16903. function stubString() {
  16904. return '';
  16905. }
  16906. /**
  16907. * This method returns `true`.
  16908. *
  16909. * @static
  16910. * @memberOf _
  16911. * @since 4.13.0
  16912. * @category Util
  16913. * @returns {boolean} Returns `true`.
  16914. * @example
  16915. *
  16916. * _.times(2, _.stubTrue);
  16917. * // => [true, true]
  16918. */
  16919. function stubTrue() {
  16920. return true;
  16921. }
  16922. /**
  16923. * Invokes the iteratee `n` times, returning an array of the results of
  16924. * each invocation. The iteratee is invoked with one argument; (index).
  16925. *
  16926. * @static
  16927. * @since 0.1.0
  16928. * @memberOf _
  16929. * @category Util
  16930. * @param {number} n The number of times to invoke `iteratee`.
  16931. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  16932. * @returns {Array} Returns the array of results.
  16933. * @example
  16934. *
  16935. * _.times(3, String);
  16936. * // => ['0', '1', '2']
  16937. *
  16938. * _.times(4, _.constant(0));
  16939. * // => [0, 0, 0, 0]
  16940. */
  16941. function times(n, iteratee) {
  16942. n = toInteger(n);
  16943. if (n < 1 || n > MAX_SAFE_INTEGER) {
  16944. return [];
  16945. }
  16946. var index = MAX_ARRAY_LENGTH,
  16947. length = nativeMin(n, MAX_ARRAY_LENGTH);
  16948. iteratee = getIteratee(iteratee);
  16949. n -= MAX_ARRAY_LENGTH;
  16950. var result = baseTimes(length, iteratee);
  16951. while (++index < n) {
  16952. iteratee(index);
  16953. }
  16954. return result;
  16955. }
  16956. /**
  16957. * Converts `value` to a property path array.
  16958. *
  16959. * @static
  16960. * @memberOf _
  16961. * @since 4.0.0
  16962. * @category Util
  16963. * @param {*} value The value to convert.
  16964. * @returns {Array} Returns the new property path array.
  16965. * @example
  16966. *
  16967. * _.toPath('a.b.c');
  16968. * // => ['a', 'b', 'c']
  16969. *
  16970. * _.toPath('a[0].b.c');
  16971. * // => ['a', '0', 'b', 'c']
  16972. */
  16973. function toPath(value) {
  16974. if (isArray(value)) {
  16975. return arrayMap(value, toKey);
  16976. }
  16977. return isSymbol(value) ? [value] : copyArray(stringToPath(toString(value)));
  16978. }
  16979. /**
  16980. * Generates a unique ID. If `prefix` is given, the ID is appended to it.
  16981. *
  16982. * @static
  16983. * @since 0.1.0
  16984. * @memberOf _
  16985. * @category Util
  16986. * @param {string} [prefix=''] The value to prefix the ID with.
  16987. * @returns {string} Returns the unique ID.
  16988. * @example
  16989. *
  16990. * _.uniqueId('contact_');
  16991. * // => 'contact_104'
  16992. *
  16993. * _.uniqueId();
  16994. * // => '105'
  16995. */
  16996. function uniqueId(prefix) {
  16997. var id = ++idCounter;
  16998. return toString(prefix) + id;
  16999. }
  17000. /*------------------------------------------------------------------------*/
  17001. /**
  17002. * Adds two numbers.
  17003. *
  17004. * @static
  17005. * @memberOf _
  17006. * @since 3.4.0
  17007. * @category Math
  17008. * @param {number} augend The first number in an addition.
  17009. * @param {number} addend The second number in an addition.
  17010. * @returns {number} Returns the total.
  17011. * @example
  17012. *
  17013. * _.add(6, 4);
  17014. * // => 10
  17015. */
  17016. var add = createMathOperation(function(augend, addend) {
  17017. return augend + addend;
  17018. }, 0);
  17019. /**
  17020. * Computes `number` rounded up to `precision`.
  17021. *
  17022. * @static
  17023. * @memberOf _
  17024. * @since 3.10.0
  17025. * @category Math
  17026. * @param {number} number The number to round up.
  17027. * @param {number} [precision=0] The precision to round up to.
  17028. * @returns {number} Returns the rounded up number.
  17029. * @example
  17030. *
  17031. * _.ceil(4.006);
  17032. * // => 5
  17033. *
  17034. * _.ceil(6.004, 2);
  17035. * // => 6.01
  17036. *
  17037. * _.ceil(6040, -2);
  17038. * // => 6100
  17039. */
  17040. var ceil = createRound('ceil');
  17041. /**
  17042. * Divide two numbers.
  17043. *
  17044. * @static
  17045. * @memberOf _
  17046. * @since 4.7.0
  17047. * @category Math
  17048. * @param {number} dividend The first number in a division.
  17049. * @param {number} divisor The second number in a division.
  17050. * @returns {number} Returns the quotient.
  17051. * @example
  17052. *
  17053. * _.divide(6, 4);
  17054. * // => 1.5
  17055. */
  17056. var divide = createMathOperation(function(dividend, divisor) {
  17057. return dividend / divisor;
  17058. }, 1);
  17059. /**
  17060. * Computes `number` rounded down to `precision`.
  17061. *
  17062. * @static
  17063. * @memberOf _
  17064. * @since 3.10.0
  17065. * @category Math
  17066. * @param {number} number The number to round down.
  17067. * @param {number} [precision=0] The precision to round down to.
  17068. * @returns {number} Returns the rounded down number.
  17069. * @example
  17070. *
  17071. * _.floor(4.006);
  17072. * // => 4
  17073. *
  17074. * _.floor(0.046, 2);
  17075. * // => 0.04
  17076. *
  17077. * _.floor(4060, -2);
  17078. * // => 4000
  17079. */
  17080. var floor = createRound('floor');
  17081. /**
  17082. * Computes the maximum value of `array`. If `array` is empty or falsey,
  17083. * `undefined` is returned.
  17084. *
  17085. * @static
  17086. * @since 0.1.0
  17087. * @memberOf _
  17088. * @category Math
  17089. * @param {Array} array The array to iterate over.
  17090. * @returns {*} Returns the maximum value.
  17091. * @example
  17092. *
  17093. * _.max([4, 2, 8, 6]);
  17094. * // => 8
  17095. *
  17096. * _.max([]);
  17097. * // => undefined
  17098. */
  17099. function max(array) {
  17100. return (array && array.length)
  17101. ? baseExtremum(array, identity, baseGt)
  17102. : undefined;
  17103. }
  17104. /**
  17105. * This method is like `_.max` except that it accepts `iteratee` which is
  17106. * invoked for each element in `array` to generate the criterion by which
  17107. * the value is ranked. The iteratee is invoked with one argument: (value).
  17108. *
  17109. * @static
  17110. * @memberOf _
  17111. * @since 4.0.0
  17112. * @category Math
  17113. * @param {Array} array The array to iterate over.
  17114. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  17115. * @returns {*} Returns the maximum value.
  17116. * @example
  17117. *
  17118. * var objects = [{ 'n': 1 }, { 'n': 2 }];
  17119. *
  17120. * _.maxBy(objects, function(o) { return o.n; });
  17121. * // => { 'n': 2 }
  17122. *
  17123. * // The `_.property` iteratee shorthand.
  17124. * _.maxBy(objects, 'n');
  17125. * // => { 'n': 2 }
  17126. */
  17127. function maxBy(array, iteratee) {
  17128. return (array && array.length)
  17129. ? baseExtremum(array, getIteratee(iteratee, 2), baseGt)
  17130. : undefined;
  17131. }
  17132. /**
  17133. * Computes the mean of the values in `array`.
  17134. *
  17135. * @static
  17136. * @memberOf _
  17137. * @since 4.0.0
  17138. * @category Math
  17139. * @param {Array} array The array to iterate over.
  17140. * @returns {number} Returns the mean.
  17141. * @example
  17142. *
  17143. * _.mean([4, 2, 8, 6]);
  17144. * // => 5
  17145. */
  17146. function mean(array) {
  17147. return baseMean(array, identity);
  17148. }
  17149. /**
  17150. * This method is like `_.mean` except that it accepts `iteratee` which is
  17151. * invoked for each element in `array` to generate the value to be averaged.
  17152. * The iteratee is invoked with one argument: (value).
  17153. *
  17154. * @static
  17155. * @memberOf _
  17156. * @since 4.7.0
  17157. * @category Math
  17158. * @param {Array} array The array to iterate over.
  17159. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  17160. * @returns {number} Returns the mean.
  17161. * @example
  17162. *
  17163. * var objects = [{ 'n': 4 }, { 'n': 2 }, { 'n': 8 }, { 'n': 6 }];
  17164. *
  17165. * _.meanBy(objects, function(o) { return o.n; });
  17166. * // => 5
  17167. *
  17168. * // The `_.property` iteratee shorthand.
  17169. * _.meanBy(objects, 'n');
  17170. * // => 5
  17171. */
  17172. function meanBy(array, iteratee) {
  17173. return baseMean(array, getIteratee(iteratee, 2));
  17174. }
  17175. /**
  17176. * Computes the minimum value of `array`. If `array` is empty or falsey,
  17177. * `undefined` is returned.
  17178. *
  17179. * @static
  17180. * @since 0.1.0
  17181. * @memberOf _
  17182. * @category Math
  17183. * @param {Array} array The array to iterate over.
  17184. * @returns {*} Returns the minimum value.
  17185. * @example
  17186. *
  17187. * _.min([4, 2, 8, 6]);
  17188. * // => 2
  17189. *
  17190. * _.min([]);
  17191. * // => undefined
  17192. */
  17193. function min(array) {
  17194. return (array && array.length)
  17195. ? baseExtremum(array, identity, baseLt)
  17196. : undefined;
  17197. }
  17198. /**
  17199. * This method is like `_.min` except that it accepts `iteratee` which is
  17200. * invoked for each element in `array` to generate the criterion by which
  17201. * the value is ranked. The iteratee is invoked with one argument: (value).
  17202. *
  17203. * @static
  17204. * @memberOf _
  17205. * @since 4.0.0
  17206. * @category Math
  17207. * @param {Array} array The array to iterate over.
  17208. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  17209. * @returns {*} Returns the minimum value.
  17210. * @example
  17211. *
  17212. * var objects = [{ 'n': 1 }, { 'n': 2 }];
  17213. *
  17214. * _.minBy(objects, function(o) { return o.n; });
  17215. * // => { 'n': 1 }
  17216. *
  17217. * // The `_.property` iteratee shorthand.
  17218. * _.minBy(objects, 'n');
  17219. * // => { 'n': 1 }
  17220. */
  17221. function minBy(array, iteratee) {
  17222. return (array && array.length)
  17223. ? baseExtremum(array, getIteratee(iteratee, 2), baseLt)
  17224. : undefined;
  17225. }
  17226. /**
  17227. * Multiply two numbers.
  17228. *
  17229. * @static
  17230. * @memberOf _
  17231. * @since 4.7.0
  17232. * @category Math
  17233. * @param {number} multiplier The first number in a multiplication.
  17234. * @param {number} multiplicand The second number in a multiplication.
  17235. * @returns {number} Returns the product.
  17236. * @example
  17237. *
  17238. * _.multiply(6, 4);
  17239. * // => 24
  17240. */
  17241. var multiply = createMathOperation(function(multiplier, multiplicand) {
  17242. return multiplier * multiplicand;
  17243. }, 1);
  17244. /**
  17245. * Computes `number` rounded to `precision`.
  17246. *
  17247. * @static
  17248. * @memberOf _
  17249. * @since 3.10.0
  17250. * @category Math
  17251. * @param {number} number The number to round.
  17252. * @param {number} [precision=0] The precision to round to.
  17253. * @returns {number} Returns the rounded number.
  17254. * @example
  17255. *
  17256. * _.round(4.006);
  17257. * // => 4
  17258. *
  17259. * _.round(4.006, 2);
  17260. * // => 4.01
  17261. *
  17262. * _.round(4060, -2);
  17263. * // => 4100
  17264. */
  17265. var round = createRound('round');
  17266. /**
  17267. * Subtract two numbers.
  17268. *
  17269. * @static
  17270. * @memberOf _
  17271. * @since 4.0.0
  17272. * @category Math
  17273. * @param {number} minuend The first number in a subtraction.
  17274. * @param {number} subtrahend The second number in a subtraction.
  17275. * @returns {number} Returns the difference.
  17276. * @example
  17277. *
  17278. * _.subtract(6, 4);
  17279. * // => 2
  17280. */
  17281. var subtract = createMathOperation(function(minuend, subtrahend) {
  17282. return minuend - subtrahend;
  17283. }, 0);
  17284. /**
  17285. * Computes the sum of the values in `array`.
  17286. *
  17287. * @static
  17288. * @memberOf _
  17289. * @since 3.4.0
  17290. * @category Math
  17291. * @param {Array} array The array to iterate over.
  17292. * @returns {number} Returns the sum.
  17293. * @example
  17294. *
  17295. * _.sum([4, 2, 8, 6]);
  17296. * // => 20
  17297. */
  17298. function sum(array) {
  17299. return (array && array.length)
  17300. ? baseSum(array, identity)
  17301. : 0;
  17302. }
  17303. /**
  17304. * This method is like `_.sum` except that it accepts `iteratee` which is
  17305. * invoked for each element in `array` to generate the value to be summed.
  17306. * The iteratee is invoked with one argument: (value).
  17307. *
  17308. * @static
  17309. * @memberOf _
  17310. * @since 4.0.0
  17311. * @category Math
  17312. * @param {Array} array The array to iterate over.
  17313. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  17314. * @returns {number} Returns the sum.
  17315. * @example
  17316. *
  17317. * var objects = [{ 'n': 4 }, { 'n': 2 }, { 'n': 8 }, { 'n': 6 }];
  17318. *
  17319. * _.sumBy(objects, function(o) { return o.n; });
  17320. * // => 20
  17321. *
  17322. * // The `_.property` iteratee shorthand.
  17323. * _.sumBy(objects, 'n');
  17324. * // => 20
  17325. */
  17326. function sumBy(array, iteratee) {
  17327. return (array && array.length)
  17328. ? baseSum(array, getIteratee(iteratee, 2))
  17329. : 0;
  17330. }
  17331. /*------------------------------------------------------------------------*/
  17332. // Add methods that return wrapped values in chain sequences.
  17333. lodash.after = after;
  17334. lodash.ary = ary;
  17335. lodash.assign = assign;
  17336. lodash.assignIn = assignIn;
  17337. lodash.assignInWith = assignInWith;
  17338. lodash.assignWith = assignWith;
  17339. lodash.at = at;
  17340. lodash.before = before;
  17341. lodash.bind = bind;
  17342. lodash.bindAll = bindAll;
  17343. lodash.bindKey = bindKey;
  17344. lodash.castArray = castArray;
  17345. lodash.chain = chain;
  17346. lodash.chunk = chunk;
  17347. lodash.compact = compact;
  17348. lodash.concat = concat;
  17349. lodash.cond = cond;
  17350. lodash.conforms = conforms;
  17351. lodash.constant = constant;
  17352. lodash.countBy = countBy;
  17353. lodash.create = create;
  17354. lodash.curry = curry;
  17355. lodash.curryRight = curryRight;
  17356. lodash.debounce = debounce;
  17357. lodash.defaults = defaults;
  17358. lodash.defaultsDeep = defaultsDeep;
  17359. lodash.defer = defer;
  17360. lodash.delay = delay;
  17361. lodash.difference = difference;
  17362. lodash.differenceBy = differenceBy;
  17363. lodash.differenceWith = differenceWith;
  17364. lodash.drop = drop;
  17365. lodash.dropRight = dropRight;
  17366. lodash.dropRightWhile = dropRightWhile;
  17367. lodash.dropWhile = dropWhile;
  17368. lodash.fill = fill;
  17369. lodash.filter = filter;
  17370. lodash.flatMap = flatMap;
  17371. lodash.flatMapDeep = flatMapDeep;
  17372. lodash.flatMapDepth = flatMapDepth;
  17373. lodash.flatten = flatten;
  17374. lodash.flattenDeep = flattenDeep;
  17375. lodash.flattenDepth = flattenDepth;
  17376. lodash.flip = flip;
  17377. lodash.flow = flow;
  17378. lodash.flowRight = flowRight;
  17379. lodash.fromPairs = fromPairs;
  17380. lodash.functions = functions;
  17381. lodash.functionsIn = functionsIn;
  17382. lodash.groupBy = groupBy;
  17383. lodash.initial = initial;
  17384. lodash.intersection = intersection;
  17385. lodash.intersectionBy = intersectionBy;
  17386. lodash.intersectionWith = intersectionWith;
  17387. lodash.invert = invert;
  17388. lodash.invertBy = invertBy;
  17389. lodash.invokeMap = invokeMap;
  17390. lodash.iteratee = iteratee;
  17391. lodash.keyBy = keyBy;
  17392. lodash.keys = keys;
  17393. lodash.keysIn = keysIn;
  17394. lodash.map = map;
  17395. lodash.mapKeys = mapKeys;
  17396. lodash.mapValues = mapValues;
  17397. lodash.matches = matches;
  17398. lodash.matchesProperty = matchesProperty;
  17399. lodash.memoize = memoize;
  17400. lodash.merge = merge;
  17401. lodash.mergeWith = mergeWith;
  17402. lodash.method = method;
  17403. lodash.methodOf = methodOf;
  17404. lodash.mixin = mixin;
  17405. lodash.negate = negate;
  17406. lodash.nthArg = nthArg;
  17407. lodash.omit = omit;
  17408. lodash.omitBy = omitBy;
  17409. lodash.once = once;
  17410. lodash.orderBy = orderBy;
  17411. lodash.over = over;
  17412. lodash.overArgs = overArgs;
  17413. lodash.overEvery = overEvery;
  17414. lodash.overSome = overSome;
  17415. lodash.partial = partial;
  17416. lodash.partialRight = partialRight;
  17417. lodash.partition = partition;
  17418. lodash.pick = pick;
  17419. lodash.pickBy = pickBy;
  17420. lodash.property = property;
  17421. lodash.propertyOf = propertyOf;
  17422. lodash.pull = pull;
  17423. lodash.pullAll = pullAll;
  17424. lodash.pullAllBy = pullAllBy;
  17425. lodash.pullAllWith = pullAllWith;
  17426. lodash.pullAt = pullAt;
  17427. lodash.range = range;
  17428. lodash.rangeRight = rangeRight;
  17429. lodash.rearg = rearg;
  17430. lodash.reject = reject;
  17431. lodash.remove = remove;
  17432. lodash.rest = rest;
  17433. lodash.reverse = reverse;
  17434. lodash.sampleSize = sampleSize;
  17435. lodash.set = set;
  17436. lodash.setWith = setWith;
  17437. lodash.shuffle = shuffle;
  17438. lodash.slice = slice;
  17439. lodash.sortBy = sortBy;
  17440. lodash.sortedUniq = sortedUniq;
  17441. lodash.sortedUniqBy = sortedUniqBy;
  17442. lodash.split = split;
  17443. lodash.spread = spread;
  17444. lodash.tail = tail;
  17445. lodash.take = take;
  17446. lodash.takeRight = takeRight;
  17447. lodash.takeRightWhile = takeRightWhile;
  17448. lodash.takeWhile = takeWhile;
  17449. lodash.tap = tap;
  17450. lodash.throttle = throttle;
  17451. lodash.thru = thru;
  17452. lodash.toArray = toArray;
  17453. lodash.toPairs = toPairs;
  17454. lodash.toPairsIn = toPairsIn;
  17455. lodash.toPath = toPath;
  17456. lodash.toPlainObject = toPlainObject;
  17457. lodash.transform = transform;
  17458. lodash.unary = unary;
  17459. lodash.union = union;
  17460. lodash.unionBy = unionBy;
  17461. lodash.unionWith = unionWith;
  17462. lodash.uniq = uniq;
  17463. lodash.uniqBy = uniqBy;
  17464. lodash.uniqWith = uniqWith;
  17465. lodash.unset = unset;
  17466. lodash.unzip = unzip;
  17467. lodash.unzipWith = unzipWith;
  17468. lodash.update = update;
  17469. lodash.updateWith = updateWith;
  17470. lodash.values = values;
  17471. lodash.valuesIn = valuesIn;
  17472. lodash.without = without;
  17473. lodash.words = words;
  17474. lodash.wrap = wrap;
  17475. lodash.xor = xor;
  17476. lodash.xorBy = xorBy;
  17477. lodash.xorWith = xorWith;
  17478. lodash.zip = zip;
  17479. lodash.zipObject = zipObject;
  17480. lodash.zipObjectDeep = zipObjectDeep;
  17481. lodash.zipWith = zipWith;
  17482. // Add aliases.
  17483. lodash.entries = toPairs;
  17484. lodash.entriesIn = toPairsIn;
  17485. lodash.extend = assignIn;
  17486. lodash.extendWith = assignInWith;
  17487. // Add methods to `lodash.prototype`.
  17488. mixin(lodash, lodash);
  17489. /*------------------------------------------------------------------------*/
  17490. // Add methods that return unwrapped values in chain sequences.
  17491. lodash.add = add;
  17492. lodash.attempt = attempt;
  17493. lodash.camelCase = camelCase;
  17494. lodash.capitalize = capitalize;
  17495. lodash.ceil = ceil;
  17496. lodash.clamp = clamp;
  17497. lodash.clone = clone;
  17498. lodash.cloneDeep = cloneDeep;
  17499. lodash.cloneDeepWith = cloneDeepWith;
  17500. lodash.cloneWith = cloneWith;
  17501. lodash.conformsTo = conformsTo;
  17502. lodash.deburr = deburr;
  17503. lodash.defaultTo = defaultTo;
  17504. lodash.divide = divide;
  17505. lodash.endsWith = endsWith;
  17506. lodash.eq = eq;
  17507. lodash.escape = escape;
  17508. lodash.escapeRegExp = escapeRegExp;
  17509. lodash.every = every;
  17510. lodash.find = find;
  17511. lodash.findIndex = findIndex;
  17512. lodash.findKey = findKey;
  17513. lodash.findLast = findLast;
  17514. lodash.findLastIndex = findLastIndex;
  17515. lodash.findLastKey = findLastKey;
  17516. lodash.floor = floor;
  17517. lodash.forEach = forEach;
  17518. lodash.forEachRight = forEachRight;
  17519. lodash.forIn = forIn;
  17520. lodash.forInRight = forInRight;
  17521. lodash.forOwn = forOwn;
  17522. lodash.forOwnRight = forOwnRight;
  17523. lodash.get = get;
  17524. lodash.gt = gt;
  17525. lodash.gte = gte;
  17526. lodash.has = has;
  17527. lodash.hasIn = hasIn;
  17528. lodash.head = head;
  17529. lodash.identity = identity;
  17530. lodash.includes = includes;
  17531. lodash.indexOf = indexOf;
  17532. lodash.inRange = inRange;
  17533. lodash.invoke = invoke;
  17534. lodash.isArguments = isArguments;
  17535. lodash.isArray = isArray;
  17536. lodash.isArrayBuffer = isArrayBuffer;
  17537. lodash.isArrayLike = isArrayLike;
  17538. lodash.isArrayLikeObject = isArrayLikeObject;
  17539. lodash.isBoolean = isBoolean;
  17540. lodash.isBuffer = isBuffer;
  17541. lodash.isDate = isDate;
  17542. lodash.isElement = isElement;
  17543. lodash.isEmpty = isEmpty;
  17544. lodash.isEqual = isEqual;
  17545. lodash.isEqualWith = isEqualWith;
  17546. lodash.isError = isError;
  17547. lodash.isFinite = isFinite;
  17548. lodash.isFunction = isFunction;
  17549. lodash.isInteger = isInteger;
  17550. lodash.isLength = isLength;
  17551. lodash.isMap = isMap;
  17552. lodash.isMatch = isMatch;
  17553. lodash.isMatchWith = isMatchWith;
  17554. lodash.isNaN = isNaN;
  17555. lodash.isNative = isNative;
  17556. lodash.isNil = isNil;
  17557. lodash.isNull = isNull;
  17558. lodash.isNumber = isNumber;
  17559. lodash.isObject = isObject;
  17560. lodash.isObjectLike = isObjectLike;
  17561. lodash.isPlainObject = isPlainObject;
  17562. lodash.isRegExp = isRegExp;
  17563. lodash.isSafeInteger = isSafeInteger;
  17564. lodash.isSet = isSet;
  17565. lodash.isString = isString;
  17566. lodash.isSymbol = isSymbol;
  17567. lodash.isTypedArray = isTypedArray;
  17568. lodash.isUndefined = isUndefined;
  17569. lodash.isWeakMap = isWeakMap;
  17570. lodash.isWeakSet = isWeakSet;
  17571. lodash.join = join;
  17572. lodash.kebabCase = kebabCase;
  17573. lodash.last = last;
  17574. lodash.lastIndexOf = lastIndexOf;
  17575. lodash.lowerCase = lowerCase;
  17576. lodash.lowerFirst = lowerFirst;
  17577. lodash.lt = lt;
  17578. lodash.lte = lte;
  17579. lodash.max = max;
  17580. lodash.maxBy = maxBy;
  17581. lodash.mean = mean;
  17582. lodash.meanBy = meanBy;
  17583. lodash.min = min;
  17584. lodash.minBy = minBy;
  17585. lodash.stubArray = stubArray;
  17586. lodash.stubFalse = stubFalse;
  17587. lodash.stubObject = stubObject;
  17588. lodash.stubString = stubString;
  17589. lodash.stubTrue = stubTrue;
  17590. lodash.multiply = multiply;
  17591. lodash.nth = nth;
  17592. lodash.noConflict = noConflict;
  17593. lodash.noop = noop;
  17594. lodash.now = now;
  17595. lodash.pad = pad;
  17596. lodash.padEnd = padEnd;
  17597. lodash.padStart = padStart;
  17598. lodash.parseInt = parseInt;
  17599. lodash.random = random;
  17600. lodash.reduce = reduce;
  17601. lodash.reduceRight = reduceRight;
  17602. lodash.repeat = repeat;
  17603. lodash.replace = replace;
  17604. lodash.result = result;
  17605. lodash.round = round;
  17606. lodash.runInContext = runInContext;
  17607. lodash.sample = sample;
  17608. lodash.size = size;
  17609. lodash.snakeCase = snakeCase;
  17610. lodash.some = some;
  17611. lodash.sortedIndex = sortedIndex;
  17612. lodash.sortedIndexBy = sortedIndexBy;
  17613. lodash.sortedIndexOf = sortedIndexOf;
  17614. lodash.sortedLastIndex = sortedLastIndex;
  17615. lodash.sortedLastIndexBy = sortedLastIndexBy;
  17616. lodash.sortedLastIndexOf = sortedLastIndexOf;
  17617. lodash.startCase = startCase;
  17618. lodash.startsWith = startsWith;
  17619. lodash.subtract = subtract;
  17620. lodash.sum = sum;
  17621. lodash.sumBy = sumBy;
  17622. lodash.template = template;
  17623. lodash.times = times;
  17624. lodash.toFinite = toFinite;
  17625. lodash.toInteger = toInteger;
  17626. lodash.toLength = toLength;
  17627. lodash.toLower = toLower;
  17628. lodash.toNumber = toNumber;
  17629. lodash.toSafeInteger = toSafeInteger;
  17630. lodash.toString = toString;
  17631. lodash.toUpper = toUpper;
  17632. lodash.trim = trim;
  17633. lodash.trimEnd = trimEnd;
  17634. lodash.trimStart = trimStart;
  17635. lodash.truncate = truncate;
  17636. lodash.unescape = unescape;
  17637. lodash.uniqueId = uniqueId;
  17638. lodash.upperCase = upperCase;
  17639. lodash.upperFirst = upperFirst;
  17640. // Add aliases.
  17641. lodash.each = forEach;
  17642. lodash.eachRight = forEachRight;
  17643. lodash.first = head;
  17644. mixin(lodash, (function() {
  17645. var source = {};
  17646. baseForOwn(lodash, function(func, methodName) {
  17647. if (!hasOwnProperty.call(lodash.prototype, methodName)) {
  17648. source[methodName] = func;
  17649. }
  17650. });
  17651. return source;
  17652. }()), { 'chain': false });
  17653. /*------------------------------------------------------------------------*/
  17654. /**
  17655. * The semantic version number.
  17656. *
  17657. * @static
  17658. * @memberOf _
  17659. * @type {string}
  17660. */
  17661. lodash.VERSION = VERSION;
  17662. // Assign default placeholders.
  17663. arrayEach(['bind', 'bindKey', 'curry', 'curryRight', 'partial', 'partialRight'], function(methodName) {
  17664. lodash[methodName].placeholder = lodash;
  17665. });
  17666. // Add `LazyWrapper` methods for `_.drop` and `_.take` variants.
  17667. arrayEach(['drop', 'take'], function(methodName, index) {
  17668. LazyWrapper.prototype[methodName] = function(n) {
  17669. n = n === undefined ? 1 : nativeMax(toInteger(n), 0);
  17670. var result = (this.__filtered__ && !index)
  17671. ? new LazyWrapper(this)
  17672. : this.clone();
  17673. if (result.__filtered__) {
  17674. result.__takeCount__ = nativeMin(n, result.__takeCount__);
  17675. } else {
  17676. result.__views__.push({
  17677. 'size': nativeMin(n, MAX_ARRAY_LENGTH),
  17678. 'type': methodName + (result.__dir__ < 0 ? 'Right' : '')
  17679. });
  17680. }
  17681. return result;
  17682. };
  17683. LazyWrapper.prototype[methodName + 'Right'] = function(n) {
  17684. return this.reverse()[methodName](n).reverse();
  17685. };
  17686. });
  17687. // Add `LazyWrapper` methods that accept an `iteratee` value.
  17688. arrayEach(['filter', 'map', 'takeWhile'], function(methodName, index) {
  17689. var type = index + 1,
  17690. isFilter = type == LAZY_FILTER_FLAG || type == LAZY_WHILE_FLAG;
  17691. LazyWrapper.prototype[methodName] = function(iteratee) {
  17692. var result = this.clone();
  17693. result.__iteratees__.push({
  17694. 'iteratee': getIteratee(iteratee, 3),
  17695. 'type': type
  17696. });
  17697. result.__filtered__ = result.__filtered__ || isFilter;
  17698. return result;
  17699. };
  17700. });
  17701. // Add `LazyWrapper` methods for `_.head` and `_.last`.
  17702. arrayEach(['head', 'last'], function(methodName, index) {
  17703. var takeName = 'take' + (index ? 'Right' : '');
  17704. LazyWrapper.prototype[methodName] = function() {
  17705. return this[takeName](1).value()[0];
  17706. };
  17707. });
  17708. // Add `LazyWrapper` methods for `_.initial` and `_.tail`.
  17709. arrayEach(['initial', 'tail'], function(methodName, index) {
  17710. var dropName = 'drop' + (index ? '' : 'Right');
  17711. LazyWrapper.prototype[methodName] = function() {
  17712. return this.__filtered__ ? new LazyWrapper(this) : this[dropName](1);
  17713. };
  17714. });
  17715. LazyWrapper.prototype.compact = function() {
  17716. return this.filter(identity);
  17717. };
  17718. LazyWrapper.prototype.find = function(predicate) {
  17719. return this.filter(predicate).head();
  17720. };
  17721. LazyWrapper.prototype.findLast = function(predicate) {
  17722. return this.reverse().find(predicate);
  17723. };
  17724. LazyWrapper.prototype.invokeMap = baseRest(function(path, args) {
  17725. if (typeof path == 'function') {
  17726. return new LazyWrapper(this);
  17727. }
  17728. return this.map(function(value) {
  17729. return baseInvoke(value, path, args);
  17730. });
  17731. });
  17732. LazyWrapper.prototype.reject = function(predicate) {
  17733. return this.filter(negate(getIteratee(predicate)));
  17734. };
  17735. LazyWrapper.prototype.slice = function(start, end) {
  17736. start = toInteger(start);
  17737. var result = this;
  17738. if (result.__filtered__ && (start > 0 || end < 0)) {
  17739. return new LazyWrapper(result);
  17740. }
  17741. if (start < 0) {
  17742. result = result.takeRight(-start);
  17743. } else if (start) {
  17744. result = result.drop(start);
  17745. }
  17746. if (end !== undefined) {
  17747. end = toInteger(end);
  17748. result = end < 0 ? result.dropRight(-end) : result.take(end - start);
  17749. }
  17750. return result;
  17751. };
  17752. LazyWrapper.prototype.takeRightWhile = function(predicate) {
  17753. return this.reverse().takeWhile(predicate).reverse();
  17754. };
  17755. LazyWrapper.prototype.toArray = function() {
  17756. return this.take(MAX_ARRAY_LENGTH);
  17757. };
  17758. // Add `LazyWrapper` methods to `lodash.prototype`.
  17759. baseForOwn(LazyWrapper.prototype, function(func, methodName) {
  17760. var checkIteratee = /^(?:filter|find|map|reject)|While$/.test(methodName),
  17761. isTaker = /^(?:head|last)$/.test(methodName),
  17762. lodashFunc = lodash[isTaker ? ('take' + (methodName == 'last' ? 'Right' : '')) : methodName],
  17763. retUnwrapped = isTaker || /^find/.test(methodName);
  17764. if (!lodashFunc) {
  17765. return;
  17766. }
  17767. lodash.prototype[methodName] = function() {
  17768. var value = this.__wrapped__,
  17769. args = isTaker ? [1] : arguments,
  17770. isLazy = value instanceof LazyWrapper,
  17771. iteratee = args[0],
  17772. useLazy = isLazy || isArray(value);
  17773. var interceptor = function(value) {
  17774. var result = lodashFunc.apply(lodash, arrayPush([value], args));
  17775. return (isTaker && chainAll) ? result[0] : result;
  17776. };
  17777. if (useLazy && checkIteratee && typeof iteratee == 'function' && iteratee.length != 1) {
  17778. // Avoid lazy use if the iteratee has a "length" value other than `1`.
  17779. isLazy = useLazy = false;
  17780. }
  17781. var chainAll = this.__chain__,
  17782. isHybrid = !!this.__actions__.length,
  17783. isUnwrapped = retUnwrapped && !chainAll,
  17784. onlyLazy = isLazy && !isHybrid;
  17785. if (!retUnwrapped && useLazy) {
  17786. value = onlyLazy ? value : new LazyWrapper(this);
  17787. var result = func.apply(value, args);
  17788. result.__actions__.push({ 'func': thru, 'args': [interceptor], 'thisArg': undefined });
  17789. return new LodashWrapper(result, chainAll);
  17790. }
  17791. if (isUnwrapped && onlyLazy) {
  17792. return func.apply(this, args);
  17793. }
  17794. result = this.thru(interceptor);
  17795. return isUnwrapped ? (isTaker ? result.value()[0] : result.value()) : result;
  17796. };
  17797. });
  17798. // Add `Array` methods to `lodash.prototype`.
  17799. arrayEach(['pop', 'push', 'shift', 'sort', 'splice', 'unshift'], function(methodName) {
  17800. var func = arrayProto[methodName],
  17801. chainName = /^(?:push|sort|unshift)$/.test(methodName) ? 'tap' : 'thru',
  17802. retUnwrapped = /^(?:pop|shift)$/.test(methodName);
  17803. lodash.prototype[methodName] = function() {
  17804. var args = arguments;
  17805. if (retUnwrapped && !this.__chain__) {
  17806. var value = this.value();
  17807. return func.apply(isArray(value) ? value : [], args);
  17808. }
  17809. return this[chainName](function(value) {
  17810. return func.apply(isArray(value) ? value : [], args);
  17811. });
  17812. };
  17813. });
  17814. // Map minified method names to their real names.
  17815. baseForOwn(LazyWrapper.prototype, function(func, methodName) {
  17816. var lodashFunc = lodash[methodName];
  17817. if (lodashFunc) {
  17818. var key = lodashFunc.name + '';
  17819. if (!hasOwnProperty.call(realNames, key)) {
  17820. realNames[key] = [];
  17821. }
  17822. realNames[key].push({ 'name': methodName, 'func': lodashFunc });
  17823. }
  17824. });
  17825. realNames[createHybrid(undefined, WRAP_BIND_KEY_FLAG).name] = [{
  17826. 'name': 'wrapper',
  17827. 'func': undefined
  17828. }];
  17829. // Add methods to `LazyWrapper`.
  17830. LazyWrapper.prototype.clone = lazyClone;
  17831. LazyWrapper.prototype.reverse = lazyReverse;
  17832. LazyWrapper.prototype.value = lazyValue;
  17833. // Add chain sequence methods to the `lodash` wrapper.
  17834. lodash.prototype.at = wrapperAt;
  17835. lodash.prototype.chain = wrapperChain;
  17836. lodash.prototype.commit = wrapperCommit;
  17837. lodash.prototype.next = wrapperNext;
  17838. lodash.prototype.plant = wrapperPlant;
  17839. lodash.prototype.reverse = wrapperReverse;
  17840. lodash.prototype.toJSON = lodash.prototype.valueOf = lodash.prototype.value = wrapperValue;
  17841. // Add lazy aliases.
  17842. lodash.prototype.first = lodash.prototype.head;
  17843. if (symIterator) {
  17844. lodash.prototype[symIterator] = wrapperToIterator;
  17845. }
  17846. return lodash;
  17847. });
  17848. /*--------------------------------------------------------------------------*/
  17849. // Export lodash.
  17850. var _ = runInContext();
  17851. // Some AMD build optimizers, like r.js, check for condition patterns like:
  17852. if (true) {
  17853. // Expose Lodash on the global object to prevent errors when Lodash is
  17854. // loaded by a script tag in the presence of an AMD loader.
  17855. // See http://requirejs.org/docs/errors.html#mismatch for more details.
  17856. // Use `_.noConflict` to remove Lodash from the global object.
  17857. root._ = _;
  17858. // Define as an anonymous module so, through path mapping, it can be
  17859. // referenced as the "underscore" module.
  17860. !(__WEBPACK_AMD_DEFINE_RESULT__ = (function() {
  17861. return _;
  17862. }).call(exports, __webpack_require__, exports, module),
  17863. __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));
  17864. }
  17865. // Check for `exports` after `define` in case a build optimizer adds it.
  17866. else {}
  17867. }.call(this));
  17868. /***/ }),
  17869. /***/ "./resources/css/app.scss":
  17870. /*!********************************!*\
  17871. !*** ./resources/css/app.scss ***!
  17872. \********************************/
  17873. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  17874. "use strict";
  17875. __webpack_require__.r(__webpack_exports__);
  17876. // extracted by mini-css-extract-plugin
  17877. /***/ }),
  17878. /***/ "./node_modules/process/browser.js":
  17879. /*!*****************************************!*\
  17880. !*** ./node_modules/process/browser.js ***!
  17881. \*****************************************/
  17882. /***/ ((module) => {
  17883. // shim for using process in browser
  17884. var process = module.exports = {};
  17885. // cached from whatever global is present so that test runners that stub it
  17886. // don't break things. But we need to wrap it in a try catch in case it is
  17887. // wrapped in strict mode code which doesn't define any globals. It's inside a
  17888. // function because try/catches deoptimize in certain engines.
  17889. var cachedSetTimeout;
  17890. var cachedClearTimeout;
  17891. function defaultSetTimout() {
  17892. throw new Error('setTimeout has not been defined');
  17893. }
  17894. function defaultClearTimeout () {
  17895. throw new Error('clearTimeout has not been defined');
  17896. }
  17897. (function () {
  17898. try {
  17899. if (typeof setTimeout === 'function') {
  17900. cachedSetTimeout = setTimeout;
  17901. } else {
  17902. cachedSetTimeout = defaultSetTimout;
  17903. }
  17904. } catch (e) {
  17905. cachedSetTimeout = defaultSetTimout;
  17906. }
  17907. try {
  17908. if (typeof clearTimeout === 'function') {
  17909. cachedClearTimeout = clearTimeout;
  17910. } else {
  17911. cachedClearTimeout = defaultClearTimeout;
  17912. }
  17913. } catch (e) {
  17914. cachedClearTimeout = defaultClearTimeout;
  17915. }
  17916. } ())
  17917. function runTimeout(fun) {
  17918. if (cachedSetTimeout === setTimeout) {
  17919. //normal enviroments in sane situations
  17920. return setTimeout(fun, 0);
  17921. }
  17922. // if setTimeout wasn't available but was latter defined
  17923. if ((cachedSetTimeout === defaultSetTimout || !cachedSetTimeout) && setTimeout) {
  17924. cachedSetTimeout = setTimeout;
  17925. return setTimeout(fun, 0);
  17926. }
  17927. try {
  17928. // when when somebody has screwed with setTimeout but no I.E. maddness
  17929. return cachedSetTimeout(fun, 0);
  17930. } catch(e){
  17931. try {
  17932. // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally
  17933. return cachedSetTimeout.call(null, fun, 0);
  17934. } catch(e){
  17935. // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error
  17936. return cachedSetTimeout.call(this, fun, 0);
  17937. }
  17938. }
  17939. }
  17940. function runClearTimeout(marker) {
  17941. if (cachedClearTimeout === clearTimeout) {
  17942. //normal enviroments in sane situations
  17943. return clearTimeout(marker);
  17944. }
  17945. // if clearTimeout wasn't available but was latter defined
  17946. if ((cachedClearTimeout === defaultClearTimeout || !cachedClearTimeout) && clearTimeout) {
  17947. cachedClearTimeout = clearTimeout;
  17948. return clearTimeout(marker);
  17949. }
  17950. try {
  17951. // when when somebody has screwed with setTimeout but no I.E. maddness
  17952. return cachedClearTimeout(marker);
  17953. } catch (e){
  17954. try {
  17955. // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally
  17956. return cachedClearTimeout.call(null, marker);
  17957. } catch (e){
  17958. // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error.
  17959. // Some versions of I.E. have different rules for clearTimeout vs setTimeout
  17960. return cachedClearTimeout.call(this, marker);
  17961. }
  17962. }
  17963. }
  17964. var queue = [];
  17965. var draining = false;
  17966. var currentQueue;
  17967. var queueIndex = -1;
  17968. function cleanUpNextTick() {
  17969. if (!draining || !currentQueue) {
  17970. return;
  17971. }
  17972. draining = false;
  17973. if (currentQueue.length) {
  17974. queue = currentQueue.concat(queue);
  17975. } else {
  17976. queueIndex = -1;
  17977. }
  17978. if (queue.length) {
  17979. drainQueue();
  17980. }
  17981. }
  17982. function drainQueue() {
  17983. if (draining) {
  17984. return;
  17985. }
  17986. var timeout = runTimeout(cleanUpNextTick);
  17987. draining = true;
  17988. var len = queue.length;
  17989. while(len) {
  17990. currentQueue = queue;
  17991. queue = [];
  17992. while (++queueIndex < len) {
  17993. if (currentQueue) {
  17994. currentQueue[queueIndex].run();
  17995. }
  17996. }
  17997. queueIndex = -1;
  17998. len = queue.length;
  17999. }
  18000. currentQueue = null;
  18001. draining = false;
  18002. runClearTimeout(timeout);
  18003. }
  18004. process.nextTick = function (fun) {
  18005. var args = new Array(arguments.length - 1);
  18006. if (arguments.length > 1) {
  18007. for (var i = 1; i < arguments.length; i++) {
  18008. args[i - 1] = arguments[i];
  18009. }
  18010. }
  18011. queue.push(new Item(fun, args));
  18012. if (queue.length === 1 && !draining) {
  18013. runTimeout(drainQueue);
  18014. }
  18015. };
  18016. // v8 likes predictible objects
  18017. function Item(fun, array) {
  18018. this.fun = fun;
  18019. this.array = array;
  18020. }
  18021. Item.prototype.run = function () {
  18022. this.fun.apply(null, this.array);
  18023. };
  18024. process.title = 'browser';
  18025. process.browser = true;
  18026. process.env = {};
  18027. process.argv = [];
  18028. process.version = ''; // empty string to avoid regexp issues
  18029. process.versions = {};
  18030. function noop() {}
  18031. process.on = noop;
  18032. process.addListener = noop;
  18033. process.once = noop;
  18034. process.off = noop;
  18035. process.removeListener = noop;
  18036. process.removeAllListeners = noop;
  18037. process.emit = noop;
  18038. process.prependListener = noop;
  18039. process.prependOnceListener = noop;
  18040. process.listeners = function (name) { return [] }
  18041. process.binding = function (name) {
  18042. throw new Error('process.binding is not supported');
  18043. };
  18044. process.cwd = function () { return '/' };
  18045. process.chdir = function (dir) {
  18046. throw new Error('process.chdir is not supported');
  18047. };
  18048. process.umask = function() { return 0; };
  18049. /***/ }),
  18050. /***/ "./node_modules/axios/package.json":
  18051. /*!*****************************************!*\
  18052. !*** ./node_modules/axios/package.json ***!
  18053. \*****************************************/
  18054. /***/ ((module) => {
  18055. "use strict";
  18056. module.exports = JSON.parse('{"_from":"axios@^0.21","_id":"axios@0.21.4","_inBundle":false,"_integrity":"sha512-ut5vewkiu8jjGBdqpM44XxjuCjq9LAKeHVmoVfHVzy8eHgxxq8SbAVQNovDA8mVi05kP0Ea/n/UzcSHcTJQfNg==","_location":"/axios","_phantomChildren":{},"_requested":{"type":"range","registry":true,"raw":"axios@^0.21","name":"axios","escapedName":"axios","rawSpec":"^0.21","saveSpec":null,"fetchSpec":"^0.21"},"_requiredBy":["#DEV:/"],"_resolved":"https://registry.npmjs.org/axios/-/axios-0.21.4.tgz","_shasum":"c67b90dc0568e5c1cf2b0b858c43ba28e2eda575","_spec":"axios@^0.21","_where":"/mnt/c/Users/Kevin/Projects/php/site/anissite","author":{"name":"Matt Zabriskie"},"browser":{"./lib/adapters/http.js":"./lib/adapters/xhr.js"},"bugs":{"url":"https://github.com/axios/axios/issues"},"bundleDependencies":false,"bundlesize":[{"path":"./dist/axios.min.js","threshold":"5kB"}],"dependencies":{"follow-redirects":"^1.14.0"},"deprecated":false,"description":"Promise based HTTP client for the browser and node.js","devDependencies":{"coveralls":"^3.0.0","es6-promise":"^4.2.4","grunt":"^1.3.0","grunt-banner":"^0.6.0","grunt-cli":"^1.2.0","grunt-contrib-clean":"^1.1.0","grunt-contrib-watch":"^1.0.0","grunt-eslint":"^23.0.0","grunt-karma":"^4.0.0","grunt-mocha-test":"^0.13.3","grunt-ts":"^6.0.0-beta.19","grunt-webpack":"^4.0.2","istanbul-instrumenter-loader":"^1.0.0","jasmine-core":"^2.4.1","karma":"^6.3.2","karma-chrome-launcher":"^3.1.0","karma-firefox-launcher":"^2.1.0","karma-jasmine":"^1.1.1","karma-jasmine-ajax":"^0.1.13","karma-safari-launcher":"^1.0.0","karma-sauce-launcher":"^4.3.6","karma-sinon":"^1.0.5","karma-sourcemap-loader":"^0.3.8","karma-webpack":"^4.0.2","load-grunt-tasks":"^3.5.2","minimist":"^1.2.0","mocha":"^8.2.1","sinon":"^4.5.0","terser-webpack-plugin":"^4.2.3","typescript":"^4.0.5","url-search-params":"^0.10.0","webpack":"^4.44.2","webpack-dev-server":"^3.11.0"},"homepage":"https://axios-http.com","jsdelivr":"dist/axios.min.js","keywords":["xhr","http","ajax","promise","node"],"license":"MIT","main":"index.js","name":"axios","repository":{"type":"git","url":"git+https://github.com/axios/axios.git"},"scripts":{"build":"NODE_ENV=production grunt build","coveralls":"cat coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js","examples":"node ./examples/server.js","fix":"eslint --fix lib/**/*.js","postversion":"git push && git push --tags","preversion":"npm test","start":"node ./sandbox/server.js","test":"grunt test","version":"npm run build && grunt version && git add -A dist && git add CHANGELOG.md bower.json package.json"},"typings":"./index.d.ts","unpkg":"dist/axios.min.js","version":"0.21.4"}');
  18057. /***/ })
  18058. /******/ });
  18059. /************************************************************************/
  18060. /******/ // The module cache
  18061. /******/ var __webpack_module_cache__ = {};
  18062. /******/
  18063. /******/ // The require function
  18064. /******/ function __webpack_require__(moduleId) {
  18065. /******/ // Check if module is in cache
  18066. /******/ var cachedModule = __webpack_module_cache__[moduleId];
  18067. /******/ if (cachedModule !== undefined) {
  18068. /******/ return cachedModule.exports;
  18069. /******/ }
  18070. /******/ // Create a new module (and put it into the cache)
  18071. /******/ var module = __webpack_module_cache__[moduleId] = {
  18072. /******/ id: moduleId,
  18073. /******/ loaded: false,
  18074. /******/ exports: {}
  18075. /******/ };
  18076. /******/
  18077. /******/ // Execute the module function
  18078. /******/ __webpack_modules__[moduleId].call(module.exports, module, module.exports, __webpack_require__);
  18079. /******/
  18080. /******/ // Flag the module as loaded
  18081. /******/ module.loaded = true;
  18082. /******/
  18083. /******/ // Return the exports of the module
  18084. /******/ return module.exports;
  18085. /******/ }
  18086. /******/
  18087. /******/ // expose the modules object (__webpack_modules__)
  18088. /******/ __webpack_require__.m = __webpack_modules__;
  18089. /******/
  18090. /************************************************************************/
  18091. /******/ /* webpack/runtime/chunk loaded */
  18092. /******/ (() => {
  18093. /******/ var deferred = [];
  18094. /******/ __webpack_require__.O = (result, chunkIds, fn, priority) => {
  18095. /******/ if(chunkIds) {
  18096. /******/ priority = priority || 0;
  18097. /******/ for(var i = deferred.length; i > 0 && deferred[i - 1][2] > priority; i--) deferred[i] = deferred[i - 1];
  18098. /******/ deferred[i] = [chunkIds, fn, priority];
  18099. /******/ return;
  18100. /******/ }
  18101. /******/ var notFulfilled = Infinity;
  18102. /******/ for (var i = 0; i < deferred.length; i++) {
  18103. /******/ var [chunkIds, fn, priority] = deferred[i];
  18104. /******/ var fulfilled = true;
  18105. /******/ for (var j = 0; j < chunkIds.length; j++) {
  18106. /******/ if ((priority & 1 === 0 || notFulfilled >= priority) && Object.keys(__webpack_require__.O).every((key) => (__webpack_require__.O[key](chunkIds[j])))) {
  18107. /******/ chunkIds.splice(j--, 1);
  18108. /******/ } else {
  18109. /******/ fulfilled = false;
  18110. /******/ if(priority < notFulfilled) notFulfilled = priority;
  18111. /******/ }
  18112. /******/ }
  18113. /******/ if(fulfilled) {
  18114. /******/ deferred.splice(i--, 1)
  18115. /******/ var r = fn();
  18116. /******/ if (r !== undefined) result = r;
  18117. /******/ }
  18118. /******/ }
  18119. /******/ return result;
  18120. /******/ };
  18121. /******/ })();
  18122. /******/
  18123. /******/ /* webpack/runtime/global */
  18124. /******/ (() => {
  18125. /******/ __webpack_require__.g = (function() {
  18126. /******/ if (typeof globalThis === 'object') return globalThis;
  18127. /******/ try {
  18128. /******/ return this || new Function('return this')();
  18129. /******/ } catch (e) {
  18130. /******/ if (typeof window === 'object') return window;
  18131. /******/ }
  18132. /******/ })();
  18133. /******/ })();
  18134. /******/
  18135. /******/ /* webpack/runtime/hasOwnProperty shorthand */
  18136. /******/ (() => {
  18137. /******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
  18138. /******/ })();
  18139. /******/
  18140. /******/ /* webpack/runtime/make namespace object */
  18141. /******/ (() => {
  18142. /******/ // define __esModule on exports
  18143. /******/ __webpack_require__.r = (exports) => {
  18144. /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
  18145. /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
  18146. /******/ }
  18147. /******/ Object.defineProperty(exports, '__esModule', { value: true });
  18148. /******/ };
  18149. /******/ })();
  18150. /******/
  18151. /******/ /* webpack/runtime/node module decorator */
  18152. /******/ (() => {
  18153. /******/ __webpack_require__.nmd = (module) => {
  18154. /******/ module.paths = [];
  18155. /******/ if (!module.children) module.children = [];
  18156. /******/ return module;
  18157. /******/ };
  18158. /******/ })();
  18159. /******/
  18160. /******/ /* webpack/runtime/jsonp chunk loading */
  18161. /******/ (() => {
  18162. /******/ // no baseURI
  18163. /******/
  18164. /******/ // object to store loaded and loading chunks
  18165. /******/ // undefined = chunk not loaded, null = chunk preloaded/prefetched
  18166. /******/ // [resolve, reject, Promise] = chunk loading, 0 = chunk loaded
  18167. /******/ var installedChunks = {
  18168. /******/ "/js/app": 0,
  18169. /******/ "css/app": 0
  18170. /******/ };
  18171. /******/
  18172. /******/ // no chunk on demand loading
  18173. /******/
  18174. /******/ // no prefetching
  18175. /******/
  18176. /******/ // no preloaded
  18177. /******/
  18178. /******/ // no HMR
  18179. /******/
  18180. /******/ // no HMR manifest
  18181. /******/
  18182. /******/ __webpack_require__.O.j = (chunkId) => (installedChunks[chunkId] === 0);
  18183. /******/
  18184. /******/ // install a JSONP callback for chunk loading
  18185. /******/ var webpackJsonpCallback = (parentChunkLoadingFunction, data) => {
  18186. /******/ var [chunkIds, moreModules, runtime] = data;
  18187. /******/ // add "moreModules" to the modules object,
  18188. /******/ // then flag all "chunkIds" as loaded and fire callback
  18189. /******/ var moduleId, chunkId, i = 0;
  18190. /******/ if(chunkIds.some((id) => (installedChunks[id] !== 0))) {
  18191. /******/ for(moduleId in moreModules) {
  18192. /******/ if(__webpack_require__.o(moreModules, moduleId)) {
  18193. /******/ __webpack_require__.m[moduleId] = moreModules[moduleId];
  18194. /******/ }
  18195. /******/ }
  18196. /******/ if(runtime) var result = runtime(__webpack_require__);
  18197. /******/ }
  18198. /******/ if(parentChunkLoadingFunction) parentChunkLoadingFunction(data);
  18199. /******/ for(;i < chunkIds.length; i++) {
  18200. /******/ chunkId = chunkIds[i];
  18201. /******/ if(__webpack_require__.o(installedChunks, chunkId) && installedChunks[chunkId]) {
  18202. /******/ installedChunks[chunkId][0]();
  18203. /******/ }
  18204. /******/ installedChunks[chunkId] = 0;
  18205. /******/ }
  18206. /******/ return __webpack_require__.O(result);
  18207. /******/ }
  18208. /******/
  18209. /******/ var chunkLoadingGlobal = self["webpackChunk"] = self["webpackChunk"] || [];
  18210. /******/ chunkLoadingGlobal.forEach(webpackJsonpCallback.bind(null, 0));
  18211. /******/ chunkLoadingGlobal.push = webpackJsonpCallback.bind(null, chunkLoadingGlobal.push.bind(chunkLoadingGlobal));
  18212. /******/ })();
  18213. /******/
  18214. /************************************************************************/
  18215. /******/
  18216. /******/ // startup
  18217. /******/ // Load entry module and return exports
  18218. /******/ // This entry module depends on other loaded chunks and execution need to be delayed
  18219. /******/ __webpack_require__.O(undefined, ["css/app"], () => (__webpack_require__("./resources/js/app.js")))
  18220. /******/ var __webpack_exports__ = __webpack_require__.O(undefined, ["css/app"], () => (__webpack_require__("./resources/css/app.scss")))
  18221. /******/ __webpack_exports__ = __webpack_require__.O(__webpack_exports__);
  18222. /******/
  18223. /******/ })()
  18224. ;