app.js 594 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316153171531815319153201532115322153231532415325153261532715328153291533015331153321533315334153351533615337153381533915340153411534215343153441534515346153471534815349153501535115352153531535415355153561535715358153591536015361153621536315364153651536615367153681536915370153711537215373153741537515376153771537815379153801538115382153831538415385153861538715388153891539015391153921539315394153951539615397153981539915400154011540215403154041540515406154071540815409154101541115412154131541415415154161541715418154191542015421154221542315424154251542615427154281542915430154311543215433154341543515436154371543815439154401544115442154431544415445154461544715448154491545015451154521545315454154551545615457154581545915460154611546215463154641546515466154671546815469154701547115472154731547415475154761547715478154791548015481154821548315484154851548615487154881548915490154911549215493154941549515496154971549815499155001550115502155031550415505155061550715508155091551015511155121551315514155151551615517155181551915520155211552215523155241552515526155271552815529155301553115532155331553415535155361553715538155391554015541155421554315544155451554615547155481554915550155511555215553155541555515556155571555815559155601556115562155631556415565155661556715568155691557015571155721557315574155751557615577155781557915580155811558215583155841558515586155871558815589155901559115592155931559415595155961559715598155991560015601156021560315604156051560615607156081560915610156111561215613156141561515616156171561815619156201562115622156231562415625156261562715628156291563015631156321563315634156351563615637156381563915640156411564215643156441564515646156471564815649156501565115652156531565415655156561565715658156591566015661156621566315664156651566615667156681566915670156711567215673156741567515676156771567815679156801568115682156831568415685156861568715688156891569015691156921569315694156951569615697156981569915700157011570215703157041570515706157071570815709157101571115712157131571415715157161571715718157191572015721157221572315724157251572615727157281572915730157311573215733157341573515736157371573815739157401574115742157431574415745157461574715748157491575015751157521575315754157551575615757157581575915760157611576215763157641576515766157671576815769157701577115772157731577415775157761577715778157791578015781157821578315784157851578615787157881578915790157911579215793157941579515796157971579815799158001580115802158031580415805158061580715808158091581015811158121581315814158151581615817158181581915820158211582215823158241582515826158271582815829158301583115832158331583415835158361583715838158391584015841158421584315844158451584615847158481584915850158511585215853158541585515856158571585815859158601586115862158631586415865158661586715868158691587015871158721587315874158751587615877158781587915880158811588215883158841588515886158871588815889158901589115892158931589415895158961589715898158991590015901159021590315904159051590615907159081590915910159111591215913159141591515916159171591815919159201592115922159231592415925159261592715928159291593015931159321593315934159351593615937159381593915940159411594215943159441594515946159471594815949159501595115952159531595415955159561595715958159591596015961159621596315964159651596615967159681596915970159711597215973159741597515976159771597815979159801598115982159831598415985159861598715988159891599015991159921599315994159951599615997159981599916000160011600216003160041600516006160071600816009160101601116012160131601416015160161601716018160191602016021160221602316024160251602616027160281602916030160311603216033160341603516036160371603816039160401604116042160431604416045160461604716048160491605016051160521605316054160551605616057160581605916060160611606216063160641606516066160671606816069160701607116072160731607416075160761607716078160791608016081160821608316084160851608616087160881608916090160911609216093160941609516096160971609816099161001610116102161031610416105161061610716108161091611016111161121611316114161151611616117161181611916120161211612216123161241612516126161271612816129161301613116132161331613416135161361613716138161391614016141161421614316144161451614616147161481614916150161511615216153161541615516156161571615816159161601616116162161631616416165161661616716168161691617016171161721617316174161751617616177161781617916180161811618216183161841618516186161871618816189161901619116192161931619416195161961619716198161991620016201162021620316204162051620616207162081620916210162111621216213162141621516216162171621816219162201622116222162231622416225162261622716228162291623016231162321623316234162351623616237162381623916240162411624216243162441624516246162471624816249162501625116252162531625416255162561625716258162591626016261162621626316264162651626616267162681626916270162711627216273162741627516276162771627816279162801628116282162831628416285162861628716288162891629016291162921629316294162951629616297162981629916300163011630216303163041630516306163071630816309163101631116312163131631416315163161631716318163191632016321163221632316324163251632616327163281632916330163311633216333163341633516336163371633816339163401634116342163431634416345163461634716348163491635016351163521635316354163551635616357163581635916360163611636216363163641636516366163671636816369163701637116372163731637416375163761637716378163791638016381163821638316384163851638616387163881638916390163911639216393163941639516396163971639816399164001640116402164031640416405164061640716408164091641016411164121641316414164151641616417164181641916420164211642216423164241642516426164271642816429164301643116432164331643416435164361643716438164391644016441164421644316444164451644616447164481644916450164511645216453164541645516456164571645816459164601646116462164631646416465164661646716468164691647016471164721647316474164751647616477164781647916480164811648216483164841648516486164871648816489164901649116492164931649416495164961649716498164991650016501165021650316504165051650616507165081650916510165111651216513165141651516516165171651816519165201652116522165231652416525165261652716528165291653016531165321653316534165351653616537165381653916540165411654216543165441654516546165471654816549165501655116552165531655416555165561655716558165591656016561165621656316564165651656616567165681656916570165711657216573165741657516576165771657816579165801658116582165831658416585165861658716588165891659016591165921659316594165951659616597165981659916600166011660216603166041660516606166071660816609166101661116612166131661416615166161661716618166191662016621166221662316624166251662616627166281662916630166311663216633166341663516636166371663816639166401664116642166431664416645166461664716648166491665016651166521665316654166551665616657166581665916660166611666216663166641666516666166671666816669166701667116672166731667416675166761667716678166791668016681166821668316684166851668616687166881668916690166911669216693166941669516696166971669816699167001670116702167031670416705167061670716708167091671016711167121671316714167151671616717167181671916720167211672216723167241672516726167271672816729167301673116732167331673416735167361673716738167391674016741167421674316744167451674616747167481674916750167511675216753167541675516756167571675816759167601676116762167631676416765167661676716768167691677016771167721677316774167751677616777167781677916780167811678216783167841678516786167871678816789167901679116792167931679416795167961679716798167991680016801168021680316804168051680616807168081680916810168111681216813168141681516816168171681816819168201682116822168231682416825168261682716828168291683016831168321683316834168351683616837168381683916840168411684216843168441684516846168471684816849168501685116852168531685416855168561685716858168591686016861168621686316864168651686616867168681686916870168711687216873168741687516876168771687816879168801688116882168831688416885168861688716888168891689016891168921689316894168951689616897168981689916900169011690216903169041690516906169071690816909169101691116912169131691416915169161691716918169191692016921169221692316924169251692616927169281692916930169311693216933169341693516936169371693816939169401694116942169431694416945169461694716948169491695016951169521695316954169551695616957169581695916960169611696216963169641696516966169671696816969169701697116972169731697416975169761697716978169791698016981169821698316984169851698616987169881698916990169911699216993169941699516996169971699816999170001700117002170031700417005170061700717008170091701017011170121701317014170151701617017170181701917020170211702217023170241702517026170271702817029170301703117032170331703417035170361703717038170391704017041170421704317044170451704617047170481704917050170511705217053170541705517056170571705817059170601706117062170631706417065170661706717068170691707017071170721707317074170751707617077170781707917080170811708217083170841708517086170871708817089170901709117092170931709417095170961709717098170991710017101171021710317104171051710617107171081710917110171111711217113171141711517116171171711817119171201712117122171231712417125171261712717128171291713017131171321713317134171351713617137171381713917140171411714217143171441714517146171471714817149171501715117152171531715417155171561715717158171591716017161171621716317164171651716617167171681716917170171711717217173171741717517176171771717817179171801718117182171831718417185171861718717188171891719017191171921719317194171951719617197171981719917200172011720217203172041720517206172071720817209172101721117212172131721417215172161721717218172191722017221172221722317224172251722617227172281722917230172311723217233172341723517236172371723817239172401724117242172431724417245172461724717248172491725017251172521725317254172551725617257172581725917260172611726217263172641726517266172671726817269172701727117272172731727417275172761727717278172791728017281172821728317284172851728617287172881728917290172911729217293172941729517296172971729817299173001730117302173031730417305173061730717308173091731017311173121731317314173151731617317173181731917320173211732217323173241732517326173271732817329173301733117332173331733417335173361733717338173391734017341173421734317344173451734617347173481734917350173511735217353173541735517356173571735817359173601736117362173631736417365173661736717368173691737017371173721737317374173751737617377173781737917380173811738217383173841738517386173871738817389173901739117392173931739417395173961739717398173991740017401174021740317404174051740617407174081740917410174111741217413174141741517416174171741817419174201742117422174231742417425174261742717428174291743017431174321743317434174351743617437174381743917440174411744217443174441744517446174471744817449174501745117452174531745417455174561745717458174591746017461174621746317464174651746617467174681746917470174711747217473174741747517476174771747817479174801748117482174831748417485174861748717488174891749017491174921749317494174951749617497174981749917500175011750217503175041750517506175071750817509175101751117512175131751417515175161751717518175191752017521175221752317524175251752617527175281752917530175311753217533175341753517536175371753817539175401754117542175431754417545175461754717548175491755017551175521755317554175551755617557175581755917560175611756217563175641756517566175671756817569175701757117572175731757417575175761757717578175791758017581175821758317584175851758617587175881758917590175911759217593175941759517596175971759817599176001760117602176031760417605176061760717608176091761017611176121761317614176151761617617176181761917620176211762217623176241762517626176271762817629176301763117632176331763417635176361763717638176391764017641176421764317644176451764617647176481764917650176511765217653176541765517656176571765817659176601766117662176631766417665176661766717668176691767017671176721767317674176751767617677176781767917680176811768217683176841768517686176871768817689176901769117692176931769417695176961769717698176991770017701177021770317704177051770617707177081770917710177111771217713177141771517716177171771817719177201772117722177231772417725177261772717728177291773017731177321773317734177351773617737177381773917740177411774217743177441774517746177471774817749177501775117752177531775417755177561775717758177591776017761177621776317764177651776617767177681776917770177711777217773177741777517776177771777817779177801778117782177831778417785177861778717788177891779017791177921779317794177951779617797177981779917800178011780217803178041780517806178071780817809178101781117812178131781417815178161781717818178191782017821178221782317824178251782617827178281782917830178311783217833178341783517836178371783817839178401784117842178431784417845178461784717848178491785017851178521785317854178551785617857178581785917860178611786217863178641786517866178671786817869178701787117872178731787417875178761787717878178791788017881178821788317884178851788617887178881788917890178911789217893178941789517896178971789817899179001790117902179031790417905179061790717908179091791017911179121791317914179151791617917179181791917920179211792217923179241792517926179271792817929179301793117932179331793417935179361793717938179391794017941179421794317944179451794617947179481794917950179511795217953179541795517956179571795817959179601796117962179631796417965179661796717968179691797017971179721797317974179751797617977179781797917980179811798217983179841798517986179871798817989179901799117992179931799417995179961799717998179991800018001180021800318004180051800618007180081800918010180111801218013180141801518016180171801818019180201802118022180231802418025180261802718028180291803018031180321803318034180351803618037180381803918040180411804218043180441804518046180471804818049180501805118052180531805418055180561805718058180591806018061180621806318064180651806618067180681806918070180711807218073180741807518076180771807818079180801808118082180831808418085180861808718088180891809018091180921809318094180951809618097180981809918100181011810218103181041810518106181071810818109181101811118112181131811418115181161811718118181191812018121181221812318124181251812618127181281812918130181311813218133181341813518136181371813818139181401814118142181431814418145181461814718148181491815018151181521815318154181551815618157181581815918160181611816218163181641816518166181671816818169181701817118172181731817418175181761817718178181791818018181181821818318184181851818618187181881818918190181911819218193181941819518196181971819818199182001820118202182031820418205182061820718208182091821018211182121821318214182151821618217182181821918220182211822218223182241822518226182271822818229182301823118232182331823418235182361823718238182391824018241182421824318244182451824618247182481824918250182511825218253182541825518256182571825818259182601826118262182631826418265182661826718268182691827018271182721827318274182751827618277182781827918280182811828218283182841828518286182871828818289182901829118292182931829418295182961829718298182991830018301183021830318304183051830618307183081830918310183111831218313183141831518316183171831818319183201832118322183231832418325183261832718328183291833018331183321833318334183351833618337183381833918340183411834218343183441834518346183471834818349183501835118352183531835418355183561835718358183591836018361183621836318364183651836618367183681836918370183711837218373183741837518376183771837818379183801838118382183831838418385183861838718388183891839018391183921839318394183951839618397183981839918400184011840218403184041840518406184071840818409184101841118412184131841418415184161841718418184191842018421184221842318424184251842618427184281842918430184311843218433184341843518436184371843818439184401844118442184431844418445184461844718448184491845018451184521845318454184551845618457184581845918460184611846218463184641846518466184671846818469184701847118472184731847418475184761847718478184791848018481184821848318484184851848618487184881848918490184911849218493184941849518496184971849818499185001850118502185031850418505185061850718508185091851018511185121851318514185151851618517185181851918520185211852218523185241852518526185271852818529185301853118532185331853418535185361853718538185391854018541185421854318544185451854618547185481854918550185511855218553185541855518556185571855818559185601856118562185631856418565185661856718568185691857018571185721857318574185751857618577185781857918580185811858218583185841858518586185871858818589185901859118592185931859418595185961859718598185991860018601186021860318604186051860618607186081860918610186111861218613186141861518616186171861818619186201862118622186231862418625186261862718628186291863018631186321863318634186351863618637186381863918640186411864218643186441864518646186471864818649186501865118652186531865418655186561865718658186591866018661186621866318664186651866618667186681866918670186711867218673186741867518676186771867818679186801868118682186831868418685186861868718688186891869018691186921869318694186951869618697186981869918700187011870218703187041870518706187071870818709187101871118712187131871418715187161871718718187191872018721187221872318724187251872618727187281872918730187311873218733187341873518736187371873818739187401874118742187431874418745187461874718748187491875018751187521875318754187551875618757187581875918760187611876218763187641876518766187671876818769187701877118772187731877418775187761877718778187791878018781187821878318784187851878618787187881878918790187911879218793187941879518796187971879818799188001880118802188031880418805188061880718808188091881018811188121881318814188151881618817188181881918820188211882218823188241882518826188271882818829188301883118832188331883418835188361883718838188391884018841188421884318844188451884618847188481884918850188511885218853188541885518856188571885818859188601886118862188631886418865188661886718868188691887018871188721887318874188751887618877188781887918880188811888218883188841888518886188871888818889188901889118892188931889418895188961889718898188991890018901189021890318904189051890618907189081890918910189111891218913189141891518916189171891818919189201892118922189231892418925189261892718928189291893018931189321893318934189351893618937189381893918940189411894218943189441894518946189471894818949189501895118952189531895418955189561895718958189591896018961189621896318964189651896618967189681896918970189711897218973189741897518976189771897818979189801898118982189831898418985189861898718988189891899018991189921899318994189951899618997189981899919000190011900219003190041900519006190071900819009190101901119012190131901419015190161901719018190191902019021190221902319024190251902619027190281902919030190311903219033190341903519036190371903819039190401904119042190431904419045190461904719048190491905019051190521905319054190551905619057190581905919060190611906219063190641906519066190671906819069190701907119072190731907419075190761907719078190791908019081190821908319084190851908619087190881908919090190911909219093190941909519096190971909819099191001910119102191031910419105191061910719108191091911019111191121911319114191151911619117191181911919120191211912219123191241912519126191271912819129191301913119132191331913419135191361913719138191391914019141191421914319144191451914619147191481914919150191511915219153191541915519156191571915819159191601916119162191631916419165191661916719168191691917019171191721917319174191751917619177191781917919180191811918219183191841918519186191871918819189191901919119192191931919419195191961919719198191991920019201192021920319204192051920619207192081920919210192111921219213192141921519216192171921819219192201922119222192231922419225192261922719228192291923019231192321923319234192351923619237192381923919240192411924219243192441924519246192471924819249192501925119252192531925419255192561925719258192591926019261192621926319264192651926619267192681926919270192711927219273192741927519276192771927819279192801928119282192831928419285192861928719288192891929019291192921929319294192951929619297192981929919300193011930219303193041930519306193071930819309193101931119312193131931419315193161931719318193191932019321193221932319324193251932619327193281932919330193311933219333193341933519336193371933819339193401934119342193431934419345193461934719348193491935019351193521935319354193551935619357193581935919360193611936219363193641936519366193671936819369193701937119372193731937419375193761937719378193791938019381193821938319384193851938619387193881938919390193911939219393
  1. /******/ (function(modules) { // webpackBootstrap
  2. /******/ // The module cache
  3. /******/ var installedModules = {};
  4. /******/
  5. /******/ // The require function
  6. /******/ function __webpack_require__(moduleId) {
  7. /******/
  8. /******/ // Check if module is in cache
  9. /******/ if(installedModules[moduleId]) {
  10. /******/ return installedModules[moduleId].exports;
  11. /******/ }
  12. /******/ // Create a new module (and put it into the cache)
  13. /******/ var module = installedModules[moduleId] = {
  14. /******/ i: moduleId,
  15. /******/ l: false,
  16. /******/ exports: {}
  17. /******/ };
  18. /******/
  19. /******/ // Execute the module function
  20. /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
  21. /******/
  22. /******/ // Flag the module as loaded
  23. /******/ module.l = true;
  24. /******/
  25. /******/ // Return the exports of the module
  26. /******/ return module.exports;
  27. /******/ }
  28. /******/
  29. /******/
  30. /******/ // expose the modules object (__webpack_modules__)
  31. /******/ __webpack_require__.m = modules;
  32. /******/
  33. /******/ // expose the module cache
  34. /******/ __webpack_require__.c = installedModules;
  35. /******/
  36. /******/ // define getter function for harmony exports
  37. /******/ __webpack_require__.d = function(exports, name, getter) {
  38. /******/ if(!__webpack_require__.o(exports, name)) {
  39. /******/ Object.defineProperty(exports, name, { enumerable: true, get: getter });
  40. /******/ }
  41. /******/ };
  42. /******/
  43. /******/ // define __esModule on exports
  44. /******/ __webpack_require__.r = function(exports) {
  45. /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
  46. /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
  47. /******/ }
  48. /******/ Object.defineProperty(exports, '__esModule', { value: true });
  49. /******/ };
  50. /******/
  51. /******/ // create a fake namespace object
  52. /******/ // mode & 1: value is a module id, require it
  53. /******/ // mode & 2: merge all properties of value into the ns
  54. /******/ // mode & 4: return value when already ns object
  55. /******/ // mode & 8|1: behave like require
  56. /******/ __webpack_require__.t = function(value, mode) {
  57. /******/ if(mode & 1) value = __webpack_require__(value);
  58. /******/ if(mode & 8) return value;
  59. /******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
  60. /******/ var ns = Object.create(null);
  61. /******/ __webpack_require__.r(ns);
  62. /******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value });
  63. /******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
  64. /******/ return ns;
  65. /******/ };
  66. /******/
  67. /******/ // getDefaultExport function for compatibility with non-harmony modules
  68. /******/ __webpack_require__.n = function(module) {
  69. /******/ var getter = module && module.__esModule ?
  70. /******/ function getDefault() { return module['default']; } :
  71. /******/ function getModuleExports() { return module; };
  72. /******/ __webpack_require__.d(getter, 'a', getter);
  73. /******/ return getter;
  74. /******/ };
  75. /******/
  76. /******/ // Object.prototype.hasOwnProperty.call
  77. /******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
  78. /******/
  79. /******/ // __webpack_public_path__
  80. /******/ __webpack_require__.p = "/";
  81. /******/
  82. /******/
  83. /******/ // Load entry module and return exports
  84. /******/ return __webpack_require__(__webpack_require__.s = 0);
  85. /******/ })
  86. /************************************************************************/
  87. /******/ ({
  88. /***/ "./node_modules/axios/index.js":
  89. /*!*************************************!*\
  90. !*** ./node_modules/axios/index.js ***!
  91. \*************************************/
  92. /*! no static exports found */
  93. /***/ (function(module, exports, __webpack_require__) {
  94. module.exports = __webpack_require__(/*! ./lib/axios */ "./node_modules/axios/lib/axios.js");
  95. /***/ }),
  96. /***/ "./node_modules/axios/lib/adapters/xhr.js":
  97. /*!************************************************!*\
  98. !*** ./node_modules/axios/lib/adapters/xhr.js ***!
  99. \************************************************/
  100. /*! no static exports found */
  101. /***/ (function(module, exports, __webpack_require__) {
  102. "use strict";
  103. var utils = __webpack_require__(/*! ./../utils */ "./node_modules/axios/lib/utils.js");
  104. var settle = __webpack_require__(/*! ./../core/settle */ "./node_modules/axios/lib/core/settle.js");
  105. var buildURL = __webpack_require__(/*! ./../helpers/buildURL */ "./node_modules/axios/lib/helpers/buildURL.js");
  106. var buildFullPath = __webpack_require__(/*! ../core/buildFullPath */ "./node_modules/axios/lib/core/buildFullPath.js");
  107. var parseHeaders = __webpack_require__(/*! ./../helpers/parseHeaders */ "./node_modules/axios/lib/helpers/parseHeaders.js");
  108. var isURLSameOrigin = __webpack_require__(/*! ./../helpers/isURLSameOrigin */ "./node_modules/axios/lib/helpers/isURLSameOrigin.js");
  109. var createError = __webpack_require__(/*! ../core/createError */ "./node_modules/axios/lib/core/createError.js");
  110. module.exports = function xhrAdapter(config) {
  111. return new Promise(function dispatchXhrRequest(resolve, reject) {
  112. var requestData = config.data;
  113. var requestHeaders = config.headers;
  114. if (utils.isFormData(requestData)) {
  115. delete requestHeaders['Content-Type']; // Let the browser set it
  116. }
  117. var request = new XMLHttpRequest();
  118. // HTTP basic authentication
  119. if (config.auth) {
  120. var username = config.auth.username || '';
  121. var password = config.auth.password || '';
  122. requestHeaders.Authorization = 'Basic ' + btoa(username + ':' + password);
  123. }
  124. var fullPath = buildFullPath(config.baseURL, config.url);
  125. request.open(config.method.toUpperCase(), buildURL(fullPath, config.params, config.paramsSerializer), true);
  126. // Set the request timeout in MS
  127. request.timeout = config.timeout;
  128. // Listen for ready state
  129. request.onreadystatechange = function handleLoad() {
  130. if (!request || request.readyState !== 4) {
  131. return;
  132. }
  133. // The request errored out and we didn't get a response, this will be
  134. // handled by onerror instead
  135. // With one exception: request that using file: protocol, most browsers
  136. // will return status as 0 even though it's a successful request
  137. if (request.status === 0 && !(request.responseURL && request.responseURL.indexOf('file:') === 0)) {
  138. return;
  139. }
  140. // Prepare the response
  141. var responseHeaders = 'getAllResponseHeaders' in request ? parseHeaders(request.getAllResponseHeaders()) : null;
  142. var responseData = !config.responseType || config.responseType === 'text' ? request.responseText : request.response;
  143. var response = {
  144. data: responseData,
  145. status: request.status,
  146. statusText: request.statusText,
  147. headers: responseHeaders,
  148. config: config,
  149. request: request
  150. };
  151. settle(resolve, reject, response);
  152. // Clean up request
  153. request = null;
  154. };
  155. // Handle browser request cancellation (as opposed to a manual cancellation)
  156. request.onabort = function handleAbort() {
  157. if (!request) {
  158. return;
  159. }
  160. reject(createError('Request aborted', config, 'ECONNABORTED', request));
  161. // Clean up request
  162. request = null;
  163. };
  164. // Handle low level network errors
  165. request.onerror = function handleError() {
  166. // Real errors are hidden from us by the browser
  167. // onerror should only fire if it's a network error
  168. reject(createError('Network Error', config, null, request));
  169. // Clean up request
  170. request = null;
  171. };
  172. // Handle timeout
  173. request.ontimeout = function handleTimeout() {
  174. var timeoutErrorMessage = 'timeout of ' + config.timeout + 'ms exceeded';
  175. if (config.timeoutErrorMessage) {
  176. timeoutErrorMessage = config.timeoutErrorMessage;
  177. }
  178. reject(createError(timeoutErrorMessage, config, 'ECONNABORTED',
  179. request));
  180. // Clean up request
  181. request = null;
  182. };
  183. // Add xsrf header
  184. // This is only done if running in a standard browser environment.
  185. // Specifically not if we're in a web worker, or react-native.
  186. if (utils.isStandardBrowserEnv()) {
  187. var cookies = __webpack_require__(/*! ./../helpers/cookies */ "./node_modules/axios/lib/helpers/cookies.js");
  188. // Add xsrf header
  189. var xsrfValue = (config.withCredentials || isURLSameOrigin(fullPath)) && config.xsrfCookieName ?
  190. cookies.read(config.xsrfCookieName) :
  191. undefined;
  192. if (xsrfValue) {
  193. requestHeaders[config.xsrfHeaderName] = xsrfValue;
  194. }
  195. }
  196. // Add headers to the request
  197. if ('setRequestHeader' in request) {
  198. utils.forEach(requestHeaders, function setRequestHeader(val, key) {
  199. if (typeof requestData === 'undefined' && key.toLowerCase() === 'content-type') {
  200. // Remove Content-Type if data is undefined
  201. delete requestHeaders[key];
  202. } else {
  203. // Otherwise add header to the request
  204. request.setRequestHeader(key, val);
  205. }
  206. });
  207. }
  208. // Add withCredentials to request if needed
  209. if (!utils.isUndefined(config.withCredentials)) {
  210. request.withCredentials = !!config.withCredentials;
  211. }
  212. // Add responseType to request if needed
  213. if (config.responseType) {
  214. try {
  215. request.responseType = config.responseType;
  216. } catch (e) {
  217. // Expected DOMException thrown by browsers not compatible XMLHttpRequest Level 2.
  218. // But, this can be suppressed for 'json' type as it can be parsed by default 'transformResponse' function.
  219. if (config.responseType !== 'json') {
  220. throw e;
  221. }
  222. }
  223. }
  224. // Handle progress if needed
  225. if (typeof config.onDownloadProgress === 'function') {
  226. request.addEventListener('progress', config.onDownloadProgress);
  227. }
  228. // Not all browsers support upload events
  229. if (typeof config.onUploadProgress === 'function' && request.upload) {
  230. request.upload.addEventListener('progress', config.onUploadProgress);
  231. }
  232. if (config.cancelToken) {
  233. // Handle cancellation
  234. config.cancelToken.promise.then(function onCanceled(cancel) {
  235. if (!request) {
  236. return;
  237. }
  238. request.abort();
  239. reject(cancel);
  240. // Clean up request
  241. request = null;
  242. });
  243. }
  244. if (requestData === undefined) {
  245. requestData = null;
  246. }
  247. // Send the request
  248. request.send(requestData);
  249. });
  250. };
  251. /***/ }),
  252. /***/ "./node_modules/axios/lib/axios.js":
  253. /*!*****************************************!*\
  254. !*** ./node_modules/axios/lib/axios.js ***!
  255. \*****************************************/
  256. /*! no static exports found */
  257. /***/ (function(module, exports, __webpack_require__) {
  258. "use strict";
  259. var utils = __webpack_require__(/*! ./utils */ "./node_modules/axios/lib/utils.js");
  260. var bind = __webpack_require__(/*! ./helpers/bind */ "./node_modules/axios/lib/helpers/bind.js");
  261. var Axios = __webpack_require__(/*! ./core/Axios */ "./node_modules/axios/lib/core/Axios.js");
  262. var mergeConfig = __webpack_require__(/*! ./core/mergeConfig */ "./node_modules/axios/lib/core/mergeConfig.js");
  263. var defaults = __webpack_require__(/*! ./defaults */ "./node_modules/axios/lib/defaults.js");
  264. /**
  265. * Create an instance of Axios
  266. *
  267. * @param {Object} defaultConfig The default config for the instance
  268. * @return {Axios} A new instance of Axios
  269. */
  270. function createInstance(defaultConfig) {
  271. var context = new Axios(defaultConfig);
  272. var instance = bind(Axios.prototype.request, context);
  273. // Copy axios.prototype to instance
  274. utils.extend(instance, Axios.prototype, context);
  275. // Copy context to instance
  276. utils.extend(instance, context);
  277. return instance;
  278. }
  279. // Create the default instance to be exported
  280. var axios = createInstance(defaults);
  281. // Expose Axios class to allow class inheritance
  282. axios.Axios = Axios;
  283. // Factory for creating new instances
  284. axios.create = function create(instanceConfig) {
  285. return createInstance(mergeConfig(axios.defaults, instanceConfig));
  286. };
  287. // Expose Cancel & CancelToken
  288. axios.Cancel = __webpack_require__(/*! ./cancel/Cancel */ "./node_modules/axios/lib/cancel/Cancel.js");
  289. axios.CancelToken = __webpack_require__(/*! ./cancel/CancelToken */ "./node_modules/axios/lib/cancel/CancelToken.js");
  290. axios.isCancel = __webpack_require__(/*! ./cancel/isCancel */ "./node_modules/axios/lib/cancel/isCancel.js");
  291. // Expose all/spread
  292. axios.all = function all(promises) {
  293. return Promise.all(promises);
  294. };
  295. axios.spread = __webpack_require__(/*! ./helpers/spread */ "./node_modules/axios/lib/helpers/spread.js");
  296. module.exports = axios;
  297. // Allow use of default import syntax in TypeScript
  298. module.exports.default = axios;
  299. /***/ }),
  300. /***/ "./node_modules/axios/lib/cancel/Cancel.js":
  301. /*!*************************************************!*\
  302. !*** ./node_modules/axios/lib/cancel/Cancel.js ***!
  303. \*************************************************/
  304. /*! no static exports found */
  305. /***/ (function(module, exports, __webpack_require__) {
  306. "use strict";
  307. /**
  308. * A `Cancel` is an object that is thrown when an operation is canceled.
  309. *
  310. * @class
  311. * @param {string=} message The message.
  312. */
  313. function Cancel(message) {
  314. this.message = message;
  315. }
  316. Cancel.prototype.toString = function toString() {
  317. return 'Cancel' + (this.message ? ': ' + this.message : '');
  318. };
  319. Cancel.prototype.__CANCEL__ = true;
  320. module.exports = Cancel;
  321. /***/ }),
  322. /***/ "./node_modules/axios/lib/cancel/CancelToken.js":
  323. /*!******************************************************!*\
  324. !*** ./node_modules/axios/lib/cancel/CancelToken.js ***!
  325. \******************************************************/
  326. /*! no static exports found */
  327. /***/ (function(module, exports, __webpack_require__) {
  328. "use strict";
  329. var Cancel = __webpack_require__(/*! ./Cancel */ "./node_modules/axios/lib/cancel/Cancel.js");
  330. /**
  331. * A `CancelToken` is an object that can be used to request cancellation of an operation.
  332. *
  333. * @class
  334. * @param {Function} executor The executor function.
  335. */
  336. function CancelToken(executor) {
  337. if (typeof executor !== 'function') {
  338. throw new TypeError('executor must be a function.');
  339. }
  340. var resolvePromise;
  341. this.promise = new Promise(function promiseExecutor(resolve) {
  342. resolvePromise = resolve;
  343. });
  344. var token = this;
  345. executor(function cancel(message) {
  346. if (token.reason) {
  347. // Cancellation has already been requested
  348. return;
  349. }
  350. token.reason = new Cancel(message);
  351. resolvePromise(token.reason);
  352. });
  353. }
  354. /**
  355. * Throws a `Cancel` if cancellation has been requested.
  356. */
  357. CancelToken.prototype.throwIfRequested = function throwIfRequested() {
  358. if (this.reason) {
  359. throw this.reason;
  360. }
  361. };
  362. /**
  363. * Returns an object that contains a new `CancelToken` and a function that, when called,
  364. * cancels the `CancelToken`.
  365. */
  366. CancelToken.source = function source() {
  367. var cancel;
  368. var token = new CancelToken(function executor(c) {
  369. cancel = c;
  370. });
  371. return {
  372. token: token,
  373. cancel: cancel
  374. };
  375. };
  376. module.exports = CancelToken;
  377. /***/ }),
  378. /***/ "./node_modules/axios/lib/cancel/isCancel.js":
  379. /*!***************************************************!*\
  380. !*** ./node_modules/axios/lib/cancel/isCancel.js ***!
  381. \***************************************************/
  382. /*! no static exports found */
  383. /***/ (function(module, exports, __webpack_require__) {
  384. "use strict";
  385. module.exports = function isCancel(value) {
  386. return !!(value && value.__CANCEL__);
  387. };
  388. /***/ }),
  389. /***/ "./node_modules/axios/lib/core/Axios.js":
  390. /*!**********************************************!*\
  391. !*** ./node_modules/axios/lib/core/Axios.js ***!
  392. \**********************************************/
  393. /*! no static exports found */
  394. /***/ (function(module, exports, __webpack_require__) {
  395. "use strict";
  396. var utils = __webpack_require__(/*! ./../utils */ "./node_modules/axios/lib/utils.js");
  397. var buildURL = __webpack_require__(/*! ../helpers/buildURL */ "./node_modules/axios/lib/helpers/buildURL.js");
  398. var InterceptorManager = __webpack_require__(/*! ./InterceptorManager */ "./node_modules/axios/lib/core/InterceptorManager.js");
  399. var dispatchRequest = __webpack_require__(/*! ./dispatchRequest */ "./node_modules/axios/lib/core/dispatchRequest.js");
  400. var mergeConfig = __webpack_require__(/*! ./mergeConfig */ "./node_modules/axios/lib/core/mergeConfig.js");
  401. /**
  402. * Create a new instance of Axios
  403. *
  404. * @param {Object} instanceConfig The default config for the instance
  405. */
  406. function Axios(instanceConfig) {
  407. this.defaults = instanceConfig;
  408. this.interceptors = {
  409. request: new InterceptorManager(),
  410. response: new InterceptorManager()
  411. };
  412. }
  413. /**
  414. * Dispatch a request
  415. *
  416. * @param {Object} config The config specific for this request (merged with this.defaults)
  417. */
  418. Axios.prototype.request = function request(config) {
  419. /*eslint no-param-reassign:0*/
  420. // Allow for axios('example/url'[, config]) a la fetch API
  421. if (typeof config === 'string') {
  422. config = arguments[1] || {};
  423. config.url = arguments[0];
  424. } else {
  425. config = config || {};
  426. }
  427. config = mergeConfig(this.defaults, config);
  428. // Set config.method
  429. if (config.method) {
  430. config.method = config.method.toLowerCase();
  431. } else if (this.defaults.method) {
  432. config.method = this.defaults.method.toLowerCase();
  433. } else {
  434. config.method = 'get';
  435. }
  436. // Hook up interceptors middleware
  437. var chain = [dispatchRequest, undefined];
  438. var promise = Promise.resolve(config);
  439. this.interceptors.request.forEach(function unshiftRequestInterceptors(interceptor) {
  440. chain.unshift(interceptor.fulfilled, interceptor.rejected);
  441. });
  442. this.interceptors.response.forEach(function pushResponseInterceptors(interceptor) {
  443. chain.push(interceptor.fulfilled, interceptor.rejected);
  444. });
  445. while (chain.length) {
  446. promise = promise.then(chain.shift(), chain.shift());
  447. }
  448. return promise;
  449. };
  450. Axios.prototype.getUri = function getUri(config) {
  451. config = mergeConfig(this.defaults, config);
  452. return buildURL(config.url, config.params, config.paramsSerializer).replace(/^\?/, '');
  453. };
  454. // Provide aliases for supported request methods
  455. utils.forEach(['delete', 'get', 'head', 'options'], function forEachMethodNoData(method) {
  456. /*eslint func-names:0*/
  457. Axios.prototype[method] = function(url, config) {
  458. return this.request(utils.merge(config || {}, {
  459. method: method,
  460. url: url
  461. }));
  462. };
  463. });
  464. utils.forEach(['post', 'put', 'patch'], function forEachMethodWithData(method) {
  465. /*eslint func-names:0*/
  466. Axios.prototype[method] = function(url, data, config) {
  467. return this.request(utils.merge(config || {}, {
  468. method: method,
  469. url: url,
  470. data: data
  471. }));
  472. };
  473. });
  474. module.exports = Axios;
  475. /***/ }),
  476. /***/ "./node_modules/axios/lib/core/InterceptorManager.js":
  477. /*!***********************************************************!*\
  478. !*** ./node_modules/axios/lib/core/InterceptorManager.js ***!
  479. \***********************************************************/
  480. /*! no static exports found */
  481. /***/ (function(module, exports, __webpack_require__) {
  482. "use strict";
  483. var utils = __webpack_require__(/*! ./../utils */ "./node_modules/axios/lib/utils.js");
  484. function InterceptorManager() {
  485. this.handlers = [];
  486. }
  487. /**
  488. * Add a new interceptor to the stack
  489. *
  490. * @param {Function} fulfilled The function to handle `then` for a `Promise`
  491. * @param {Function} rejected The function to handle `reject` for a `Promise`
  492. *
  493. * @return {Number} An ID used to remove interceptor later
  494. */
  495. InterceptorManager.prototype.use = function use(fulfilled, rejected) {
  496. this.handlers.push({
  497. fulfilled: fulfilled,
  498. rejected: rejected
  499. });
  500. return this.handlers.length - 1;
  501. };
  502. /**
  503. * Remove an interceptor from the stack
  504. *
  505. * @param {Number} id The ID that was returned by `use`
  506. */
  507. InterceptorManager.prototype.eject = function eject(id) {
  508. if (this.handlers[id]) {
  509. this.handlers[id] = null;
  510. }
  511. };
  512. /**
  513. * Iterate over all the registered interceptors
  514. *
  515. * This method is particularly useful for skipping over any
  516. * interceptors that may have become `null` calling `eject`.
  517. *
  518. * @param {Function} fn The function to call for each interceptor
  519. */
  520. InterceptorManager.prototype.forEach = function forEach(fn) {
  521. utils.forEach(this.handlers, function forEachHandler(h) {
  522. if (h !== null) {
  523. fn(h);
  524. }
  525. });
  526. };
  527. module.exports = InterceptorManager;
  528. /***/ }),
  529. /***/ "./node_modules/axios/lib/core/buildFullPath.js":
  530. /*!******************************************************!*\
  531. !*** ./node_modules/axios/lib/core/buildFullPath.js ***!
  532. \******************************************************/
  533. /*! no static exports found */
  534. /***/ (function(module, exports, __webpack_require__) {
  535. "use strict";
  536. var isAbsoluteURL = __webpack_require__(/*! ../helpers/isAbsoluteURL */ "./node_modules/axios/lib/helpers/isAbsoluteURL.js");
  537. var combineURLs = __webpack_require__(/*! ../helpers/combineURLs */ "./node_modules/axios/lib/helpers/combineURLs.js");
  538. /**
  539. * Creates a new URL by combining the baseURL with the requestedURL,
  540. * only when the requestedURL is not already an absolute URL.
  541. * If the requestURL is absolute, this function returns the requestedURL untouched.
  542. *
  543. * @param {string} baseURL The base URL
  544. * @param {string} requestedURL Absolute or relative URL to combine
  545. * @returns {string} The combined full path
  546. */
  547. module.exports = function buildFullPath(baseURL, requestedURL) {
  548. if (baseURL && !isAbsoluteURL(requestedURL)) {
  549. return combineURLs(baseURL, requestedURL);
  550. }
  551. return requestedURL;
  552. };
  553. /***/ }),
  554. /***/ "./node_modules/axios/lib/core/createError.js":
  555. /*!****************************************************!*\
  556. !*** ./node_modules/axios/lib/core/createError.js ***!
  557. \****************************************************/
  558. /*! no static exports found */
  559. /***/ (function(module, exports, __webpack_require__) {
  560. "use strict";
  561. var enhanceError = __webpack_require__(/*! ./enhanceError */ "./node_modules/axios/lib/core/enhanceError.js");
  562. /**
  563. * Create an Error with the specified message, config, error code, request and response.
  564. *
  565. * @param {string} message The error message.
  566. * @param {Object} config The config.
  567. * @param {string} [code] The error code (for example, 'ECONNABORTED').
  568. * @param {Object} [request] The request.
  569. * @param {Object} [response] The response.
  570. * @returns {Error} The created error.
  571. */
  572. module.exports = function createError(message, config, code, request, response) {
  573. var error = new Error(message);
  574. return enhanceError(error, config, code, request, response);
  575. };
  576. /***/ }),
  577. /***/ "./node_modules/axios/lib/core/dispatchRequest.js":
  578. /*!********************************************************!*\
  579. !*** ./node_modules/axios/lib/core/dispatchRequest.js ***!
  580. \********************************************************/
  581. /*! no static exports found */
  582. /***/ (function(module, exports, __webpack_require__) {
  583. "use strict";
  584. var utils = __webpack_require__(/*! ./../utils */ "./node_modules/axios/lib/utils.js");
  585. var transformData = __webpack_require__(/*! ./transformData */ "./node_modules/axios/lib/core/transformData.js");
  586. var isCancel = __webpack_require__(/*! ../cancel/isCancel */ "./node_modules/axios/lib/cancel/isCancel.js");
  587. var defaults = __webpack_require__(/*! ../defaults */ "./node_modules/axios/lib/defaults.js");
  588. /**
  589. * Throws a `Cancel` if cancellation has been requested.
  590. */
  591. function throwIfCancellationRequested(config) {
  592. if (config.cancelToken) {
  593. config.cancelToken.throwIfRequested();
  594. }
  595. }
  596. /**
  597. * Dispatch a request to the server using the configured adapter.
  598. *
  599. * @param {object} config The config that is to be used for the request
  600. * @returns {Promise} The Promise to be fulfilled
  601. */
  602. module.exports = function dispatchRequest(config) {
  603. throwIfCancellationRequested(config);
  604. // Ensure headers exist
  605. config.headers = config.headers || {};
  606. // Transform request data
  607. config.data = transformData(
  608. config.data,
  609. config.headers,
  610. config.transformRequest
  611. );
  612. // Flatten headers
  613. config.headers = utils.merge(
  614. config.headers.common || {},
  615. config.headers[config.method] || {},
  616. config.headers
  617. );
  618. utils.forEach(
  619. ['delete', 'get', 'head', 'post', 'put', 'patch', 'common'],
  620. function cleanHeaderConfig(method) {
  621. delete config.headers[method];
  622. }
  623. );
  624. var adapter = config.adapter || defaults.adapter;
  625. return adapter(config).then(function onAdapterResolution(response) {
  626. throwIfCancellationRequested(config);
  627. // Transform response data
  628. response.data = transformData(
  629. response.data,
  630. response.headers,
  631. config.transformResponse
  632. );
  633. return response;
  634. }, function onAdapterRejection(reason) {
  635. if (!isCancel(reason)) {
  636. throwIfCancellationRequested(config);
  637. // Transform response data
  638. if (reason && reason.response) {
  639. reason.response.data = transformData(
  640. reason.response.data,
  641. reason.response.headers,
  642. config.transformResponse
  643. );
  644. }
  645. }
  646. return Promise.reject(reason);
  647. });
  648. };
  649. /***/ }),
  650. /***/ "./node_modules/axios/lib/core/enhanceError.js":
  651. /*!*****************************************************!*\
  652. !*** ./node_modules/axios/lib/core/enhanceError.js ***!
  653. \*****************************************************/
  654. /*! no static exports found */
  655. /***/ (function(module, exports, __webpack_require__) {
  656. "use strict";
  657. /**
  658. * Update an Error with the specified config, error code, and response.
  659. *
  660. * @param {Error} error The error to update.
  661. * @param {Object} config The config.
  662. * @param {string} [code] The error code (for example, 'ECONNABORTED').
  663. * @param {Object} [request] The request.
  664. * @param {Object} [response] The response.
  665. * @returns {Error} The error.
  666. */
  667. module.exports = function enhanceError(error, config, code, request, response) {
  668. error.config = config;
  669. if (code) {
  670. error.code = code;
  671. }
  672. error.request = request;
  673. error.response = response;
  674. error.isAxiosError = true;
  675. error.toJSON = function() {
  676. return {
  677. // Standard
  678. message: this.message,
  679. name: this.name,
  680. // Microsoft
  681. description: this.description,
  682. number: this.number,
  683. // Mozilla
  684. fileName: this.fileName,
  685. lineNumber: this.lineNumber,
  686. columnNumber: this.columnNumber,
  687. stack: this.stack,
  688. // Axios
  689. config: this.config,
  690. code: this.code
  691. };
  692. };
  693. return error;
  694. };
  695. /***/ }),
  696. /***/ "./node_modules/axios/lib/core/mergeConfig.js":
  697. /*!****************************************************!*\
  698. !*** ./node_modules/axios/lib/core/mergeConfig.js ***!
  699. \****************************************************/
  700. /*! no static exports found */
  701. /***/ (function(module, exports, __webpack_require__) {
  702. "use strict";
  703. var utils = __webpack_require__(/*! ../utils */ "./node_modules/axios/lib/utils.js");
  704. /**
  705. * Config-specific merge-function which creates a new config-object
  706. * by merging two configuration objects together.
  707. *
  708. * @param {Object} config1
  709. * @param {Object} config2
  710. * @returns {Object} New object resulting from merging config2 to config1
  711. */
  712. module.exports = function mergeConfig(config1, config2) {
  713. // eslint-disable-next-line no-param-reassign
  714. config2 = config2 || {};
  715. var config = {};
  716. var valueFromConfig2Keys = ['url', 'method', 'params', 'data'];
  717. var mergeDeepPropertiesKeys = ['headers', 'auth', 'proxy'];
  718. var defaultToConfig2Keys = [
  719. 'baseURL', 'url', 'transformRequest', 'transformResponse', 'paramsSerializer',
  720. 'timeout', 'withCredentials', 'adapter', 'responseType', 'xsrfCookieName',
  721. 'xsrfHeaderName', 'onUploadProgress', 'onDownloadProgress',
  722. 'maxContentLength', 'validateStatus', 'maxRedirects', 'httpAgent',
  723. 'httpsAgent', 'cancelToken', 'socketPath'
  724. ];
  725. utils.forEach(valueFromConfig2Keys, function valueFromConfig2(prop) {
  726. if (typeof config2[prop] !== 'undefined') {
  727. config[prop] = config2[prop];
  728. }
  729. });
  730. utils.forEach(mergeDeepPropertiesKeys, function mergeDeepProperties(prop) {
  731. if (utils.isObject(config2[prop])) {
  732. config[prop] = utils.deepMerge(config1[prop], config2[prop]);
  733. } else if (typeof config2[prop] !== 'undefined') {
  734. config[prop] = config2[prop];
  735. } else if (utils.isObject(config1[prop])) {
  736. config[prop] = utils.deepMerge(config1[prop]);
  737. } else if (typeof config1[prop] !== 'undefined') {
  738. config[prop] = config1[prop];
  739. }
  740. });
  741. utils.forEach(defaultToConfig2Keys, function defaultToConfig2(prop) {
  742. if (typeof config2[prop] !== 'undefined') {
  743. config[prop] = config2[prop];
  744. } else if (typeof config1[prop] !== 'undefined') {
  745. config[prop] = config1[prop];
  746. }
  747. });
  748. var axiosKeys = valueFromConfig2Keys
  749. .concat(mergeDeepPropertiesKeys)
  750. .concat(defaultToConfig2Keys);
  751. var otherKeys = Object
  752. .keys(config2)
  753. .filter(function filterAxiosKeys(key) {
  754. return axiosKeys.indexOf(key) === -1;
  755. });
  756. utils.forEach(otherKeys, function otherKeysDefaultToConfig2(prop) {
  757. if (typeof config2[prop] !== 'undefined') {
  758. config[prop] = config2[prop];
  759. } else if (typeof config1[prop] !== 'undefined') {
  760. config[prop] = config1[prop];
  761. }
  762. });
  763. return config;
  764. };
  765. /***/ }),
  766. /***/ "./node_modules/axios/lib/core/settle.js":
  767. /*!***********************************************!*\
  768. !*** ./node_modules/axios/lib/core/settle.js ***!
  769. \***********************************************/
  770. /*! no static exports found */
  771. /***/ (function(module, exports, __webpack_require__) {
  772. "use strict";
  773. var createError = __webpack_require__(/*! ./createError */ "./node_modules/axios/lib/core/createError.js");
  774. /**
  775. * Resolve or reject a Promise based on response status.
  776. *
  777. * @param {Function} resolve A function that resolves the promise.
  778. * @param {Function} reject A function that rejects the promise.
  779. * @param {object} response The response.
  780. */
  781. module.exports = function settle(resolve, reject, response) {
  782. var validateStatus = response.config.validateStatus;
  783. if (!validateStatus || validateStatus(response.status)) {
  784. resolve(response);
  785. } else {
  786. reject(createError(
  787. 'Request failed with status code ' + response.status,
  788. response.config,
  789. null,
  790. response.request,
  791. response
  792. ));
  793. }
  794. };
  795. /***/ }),
  796. /***/ "./node_modules/axios/lib/core/transformData.js":
  797. /*!******************************************************!*\
  798. !*** ./node_modules/axios/lib/core/transformData.js ***!
  799. \******************************************************/
  800. /*! no static exports found */
  801. /***/ (function(module, exports, __webpack_require__) {
  802. "use strict";
  803. var utils = __webpack_require__(/*! ./../utils */ "./node_modules/axios/lib/utils.js");
  804. /**
  805. * Transform the data for a request or a response
  806. *
  807. * @param {Object|String} data The data to be transformed
  808. * @param {Array} headers The headers for the request or response
  809. * @param {Array|Function} fns A single function or Array of functions
  810. * @returns {*} The resulting transformed data
  811. */
  812. module.exports = function transformData(data, headers, fns) {
  813. /*eslint no-param-reassign:0*/
  814. utils.forEach(fns, function transform(fn) {
  815. data = fn(data, headers);
  816. });
  817. return data;
  818. };
  819. /***/ }),
  820. /***/ "./node_modules/axios/lib/defaults.js":
  821. /*!********************************************!*\
  822. !*** ./node_modules/axios/lib/defaults.js ***!
  823. \********************************************/
  824. /*! no static exports found */
  825. /***/ (function(module, exports, __webpack_require__) {
  826. "use strict";
  827. /* WEBPACK VAR INJECTION */(function(process) {
  828. var utils = __webpack_require__(/*! ./utils */ "./node_modules/axios/lib/utils.js");
  829. var normalizeHeaderName = __webpack_require__(/*! ./helpers/normalizeHeaderName */ "./node_modules/axios/lib/helpers/normalizeHeaderName.js");
  830. var DEFAULT_CONTENT_TYPE = {
  831. 'Content-Type': 'application/x-www-form-urlencoded'
  832. };
  833. function setContentTypeIfUnset(headers, value) {
  834. if (!utils.isUndefined(headers) && utils.isUndefined(headers['Content-Type'])) {
  835. headers['Content-Type'] = value;
  836. }
  837. }
  838. function getDefaultAdapter() {
  839. var adapter;
  840. if (typeof XMLHttpRequest !== 'undefined') {
  841. // For browsers use XHR adapter
  842. adapter = __webpack_require__(/*! ./adapters/xhr */ "./node_modules/axios/lib/adapters/xhr.js");
  843. } else if (typeof process !== 'undefined' && Object.prototype.toString.call(process) === '[object process]') {
  844. // For node use HTTP adapter
  845. adapter = __webpack_require__(/*! ./adapters/http */ "./node_modules/axios/lib/adapters/xhr.js");
  846. }
  847. return adapter;
  848. }
  849. var defaults = {
  850. adapter: getDefaultAdapter(),
  851. transformRequest: [function transformRequest(data, headers) {
  852. normalizeHeaderName(headers, 'Accept');
  853. normalizeHeaderName(headers, 'Content-Type');
  854. if (utils.isFormData(data) ||
  855. utils.isArrayBuffer(data) ||
  856. utils.isBuffer(data) ||
  857. utils.isStream(data) ||
  858. utils.isFile(data) ||
  859. utils.isBlob(data)
  860. ) {
  861. return data;
  862. }
  863. if (utils.isArrayBufferView(data)) {
  864. return data.buffer;
  865. }
  866. if (utils.isURLSearchParams(data)) {
  867. setContentTypeIfUnset(headers, 'application/x-www-form-urlencoded;charset=utf-8');
  868. return data.toString();
  869. }
  870. if (utils.isObject(data)) {
  871. setContentTypeIfUnset(headers, 'application/json;charset=utf-8');
  872. return JSON.stringify(data);
  873. }
  874. return data;
  875. }],
  876. transformResponse: [function transformResponse(data) {
  877. /*eslint no-param-reassign:0*/
  878. if (typeof data === 'string') {
  879. try {
  880. data = JSON.parse(data);
  881. } catch (e) { /* Ignore */ }
  882. }
  883. return data;
  884. }],
  885. /**
  886. * A timeout in milliseconds to abort a request. If set to 0 (default) a
  887. * timeout is not created.
  888. */
  889. timeout: 0,
  890. xsrfCookieName: 'XSRF-TOKEN',
  891. xsrfHeaderName: 'X-XSRF-TOKEN',
  892. maxContentLength: -1,
  893. validateStatus: function validateStatus(status) {
  894. return status >= 200 && status < 300;
  895. }
  896. };
  897. defaults.headers = {
  898. common: {
  899. 'Accept': 'application/json, text/plain, */*'
  900. }
  901. };
  902. utils.forEach(['delete', 'get', 'head'], function forEachMethodNoData(method) {
  903. defaults.headers[method] = {};
  904. });
  905. utils.forEach(['post', 'put', 'patch'], function forEachMethodWithData(method) {
  906. defaults.headers[method] = utils.merge(DEFAULT_CONTENT_TYPE);
  907. });
  908. module.exports = defaults;
  909. /* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! ./../../process/browser.js */ "./node_modules/process/browser.js")))
  910. /***/ }),
  911. /***/ "./node_modules/axios/lib/helpers/bind.js":
  912. /*!************************************************!*\
  913. !*** ./node_modules/axios/lib/helpers/bind.js ***!
  914. \************************************************/
  915. /*! no static exports found */
  916. /***/ (function(module, exports, __webpack_require__) {
  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. /*! no static exports found */
  933. /***/ (function(module, exports, __webpack_require__) {
  934. "use strict";
  935. var utils = __webpack_require__(/*! ./../utils */ "./node_modules/axios/lib/utils.js");
  936. function encode(val) {
  937. return encodeURIComponent(val).
  938. replace(/%40/gi, '@').
  939. replace(/%3A/gi, ':').
  940. replace(/%24/g, '$').
  941. replace(/%2C/gi, ',').
  942. replace(/%20/g, '+').
  943. replace(/%5B/gi, '[').
  944. replace(/%5D/gi, ']');
  945. }
  946. /**
  947. * Build a URL by appending params to the end
  948. *
  949. * @param {string} url The base of the url (e.g., http://www.google.com)
  950. * @param {object} [params] The params to be appended
  951. * @returns {string} The formatted url
  952. */
  953. module.exports = function buildURL(url, params, paramsSerializer) {
  954. /*eslint no-param-reassign:0*/
  955. if (!params) {
  956. return url;
  957. }
  958. var serializedParams;
  959. if (paramsSerializer) {
  960. serializedParams = paramsSerializer(params);
  961. } else if (utils.isURLSearchParams(params)) {
  962. serializedParams = params.toString();
  963. } else {
  964. var parts = [];
  965. utils.forEach(params, function serialize(val, key) {
  966. if (val === null || typeof val === 'undefined') {
  967. return;
  968. }
  969. if (utils.isArray(val)) {
  970. key = key + '[]';
  971. } else {
  972. val = [val];
  973. }
  974. utils.forEach(val, function parseValue(v) {
  975. if (utils.isDate(v)) {
  976. v = v.toISOString();
  977. } else if (utils.isObject(v)) {
  978. v = JSON.stringify(v);
  979. }
  980. parts.push(encode(key) + '=' + encode(v));
  981. });
  982. });
  983. serializedParams = parts.join('&');
  984. }
  985. if (serializedParams) {
  986. var hashmarkIndex = url.indexOf('#');
  987. if (hashmarkIndex !== -1) {
  988. url = url.slice(0, hashmarkIndex);
  989. }
  990. url += (url.indexOf('?') === -1 ? '?' : '&') + serializedParams;
  991. }
  992. return url;
  993. };
  994. /***/ }),
  995. /***/ "./node_modules/axios/lib/helpers/combineURLs.js":
  996. /*!*******************************************************!*\
  997. !*** ./node_modules/axios/lib/helpers/combineURLs.js ***!
  998. \*******************************************************/
  999. /*! no static exports found */
  1000. /***/ (function(module, exports, __webpack_require__) {
  1001. "use strict";
  1002. /**
  1003. * Creates a new URL by combining the specified URLs
  1004. *
  1005. * @param {string} baseURL The base URL
  1006. * @param {string} relativeURL The relative URL
  1007. * @returns {string} The combined URL
  1008. */
  1009. module.exports = function combineURLs(baseURL, relativeURL) {
  1010. return relativeURL
  1011. ? baseURL.replace(/\/+$/, '') + '/' + relativeURL.replace(/^\/+/, '')
  1012. : baseURL;
  1013. };
  1014. /***/ }),
  1015. /***/ "./node_modules/axios/lib/helpers/cookies.js":
  1016. /*!***************************************************!*\
  1017. !*** ./node_modules/axios/lib/helpers/cookies.js ***!
  1018. \***************************************************/
  1019. /*! no static exports found */
  1020. /***/ (function(module, exports, __webpack_require__) {
  1021. "use strict";
  1022. var utils = __webpack_require__(/*! ./../utils */ "./node_modules/axios/lib/utils.js");
  1023. module.exports = (
  1024. utils.isStandardBrowserEnv() ?
  1025. // Standard browser envs support document.cookie
  1026. (function standardBrowserEnv() {
  1027. return {
  1028. write: function write(name, value, expires, path, domain, secure) {
  1029. var cookie = [];
  1030. cookie.push(name + '=' + encodeURIComponent(value));
  1031. if (utils.isNumber(expires)) {
  1032. cookie.push('expires=' + new Date(expires).toGMTString());
  1033. }
  1034. if (utils.isString(path)) {
  1035. cookie.push('path=' + path);
  1036. }
  1037. if (utils.isString(domain)) {
  1038. cookie.push('domain=' + domain);
  1039. }
  1040. if (secure === true) {
  1041. cookie.push('secure');
  1042. }
  1043. document.cookie = cookie.join('; ');
  1044. },
  1045. read: function read(name) {
  1046. var match = document.cookie.match(new RegExp('(^|;\\s*)(' + name + ')=([^;]*)'));
  1047. return (match ? decodeURIComponent(match[3]) : null);
  1048. },
  1049. remove: function remove(name) {
  1050. this.write(name, '', Date.now() - 86400000);
  1051. }
  1052. };
  1053. })() :
  1054. // Non standard browser env (web workers, react-native) lack needed support.
  1055. (function nonStandardBrowserEnv() {
  1056. return {
  1057. write: function write() {},
  1058. read: function read() { return null; },
  1059. remove: function remove() {}
  1060. };
  1061. })()
  1062. );
  1063. /***/ }),
  1064. /***/ "./node_modules/axios/lib/helpers/isAbsoluteURL.js":
  1065. /*!*********************************************************!*\
  1066. !*** ./node_modules/axios/lib/helpers/isAbsoluteURL.js ***!
  1067. \*********************************************************/
  1068. /*! no static exports found */
  1069. /***/ (function(module, exports, __webpack_require__) {
  1070. "use strict";
  1071. /**
  1072. * Determines whether the specified URL is absolute
  1073. *
  1074. * @param {string} url The URL to test
  1075. * @returns {boolean} True if the specified URL is absolute, otherwise false
  1076. */
  1077. module.exports = function isAbsoluteURL(url) {
  1078. // A URL is considered absolute if it begins with "<scheme>://" or "//" (protocol-relative URL).
  1079. // RFC 3986 defines scheme name as a sequence of characters beginning with a letter and followed
  1080. // by any combination of letters, digits, plus, period, or hyphen.
  1081. return /^([a-z][a-z\d\+\-\.]*:)?\/\//i.test(url);
  1082. };
  1083. /***/ }),
  1084. /***/ "./node_modules/axios/lib/helpers/isURLSameOrigin.js":
  1085. /*!***********************************************************!*\
  1086. !*** ./node_modules/axios/lib/helpers/isURLSameOrigin.js ***!
  1087. \***********************************************************/
  1088. /*! no static exports found */
  1089. /***/ (function(module, exports, __webpack_require__) {
  1090. "use strict";
  1091. var utils = __webpack_require__(/*! ./../utils */ "./node_modules/axios/lib/utils.js");
  1092. module.exports = (
  1093. utils.isStandardBrowserEnv() ?
  1094. // Standard browser envs have full support of the APIs needed to test
  1095. // whether the request URL is of the same origin as current location.
  1096. (function standardBrowserEnv() {
  1097. var msie = /(msie|trident)/i.test(navigator.userAgent);
  1098. var urlParsingNode = document.createElement('a');
  1099. var originURL;
  1100. /**
  1101. * Parse a URL to discover it's components
  1102. *
  1103. * @param {String} url The URL to be parsed
  1104. * @returns {Object}
  1105. */
  1106. function resolveURL(url) {
  1107. var href = url;
  1108. if (msie) {
  1109. // IE needs attribute set twice to normalize properties
  1110. urlParsingNode.setAttribute('href', href);
  1111. href = urlParsingNode.href;
  1112. }
  1113. urlParsingNode.setAttribute('href', href);
  1114. // urlParsingNode provides the UrlUtils interface - http://url.spec.whatwg.org/#urlutils
  1115. return {
  1116. href: urlParsingNode.href,
  1117. protocol: urlParsingNode.protocol ? urlParsingNode.protocol.replace(/:$/, '') : '',
  1118. host: urlParsingNode.host,
  1119. search: urlParsingNode.search ? urlParsingNode.search.replace(/^\?/, '') : '',
  1120. hash: urlParsingNode.hash ? urlParsingNode.hash.replace(/^#/, '') : '',
  1121. hostname: urlParsingNode.hostname,
  1122. port: urlParsingNode.port,
  1123. pathname: (urlParsingNode.pathname.charAt(0) === '/') ?
  1124. urlParsingNode.pathname :
  1125. '/' + urlParsingNode.pathname
  1126. };
  1127. }
  1128. originURL = resolveURL(window.location.href);
  1129. /**
  1130. * Determine if a URL shares the same origin as the current location
  1131. *
  1132. * @param {String} requestURL The URL to test
  1133. * @returns {boolean} True if URL shares the same origin, otherwise false
  1134. */
  1135. return function isURLSameOrigin(requestURL) {
  1136. var parsed = (utils.isString(requestURL)) ? resolveURL(requestURL) : requestURL;
  1137. return (parsed.protocol === originURL.protocol &&
  1138. parsed.host === originURL.host);
  1139. };
  1140. })() :
  1141. // Non standard browser envs (web workers, react-native) lack needed support.
  1142. (function nonStandardBrowserEnv() {
  1143. return function isURLSameOrigin() {
  1144. return true;
  1145. };
  1146. })()
  1147. );
  1148. /***/ }),
  1149. /***/ "./node_modules/axios/lib/helpers/normalizeHeaderName.js":
  1150. /*!***************************************************************!*\
  1151. !*** ./node_modules/axios/lib/helpers/normalizeHeaderName.js ***!
  1152. \***************************************************************/
  1153. /*! no static exports found */
  1154. /***/ (function(module, exports, __webpack_require__) {
  1155. "use strict";
  1156. var utils = __webpack_require__(/*! ../utils */ "./node_modules/axios/lib/utils.js");
  1157. module.exports = function normalizeHeaderName(headers, normalizedName) {
  1158. utils.forEach(headers, function processHeader(value, name) {
  1159. if (name !== normalizedName && name.toUpperCase() === normalizedName.toUpperCase()) {
  1160. headers[normalizedName] = value;
  1161. delete headers[name];
  1162. }
  1163. });
  1164. };
  1165. /***/ }),
  1166. /***/ "./node_modules/axios/lib/helpers/parseHeaders.js":
  1167. /*!********************************************************!*\
  1168. !*** ./node_modules/axios/lib/helpers/parseHeaders.js ***!
  1169. \********************************************************/
  1170. /*! no static exports found */
  1171. /***/ (function(module, exports, __webpack_require__) {
  1172. "use strict";
  1173. var utils = __webpack_require__(/*! ./../utils */ "./node_modules/axios/lib/utils.js");
  1174. // Headers whose duplicates are ignored by node
  1175. // c.f. https://nodejs.org/api/http.html#http_message_headers
  1176. var ignoreDuplicateOf = [
  1177. 'age', 'authorization', 'content-length', 'content-type', 'etag',
  1178. 'expires', 'from', 'host', 'if-modified-since', 'if-unmodified-since',
  1179. 'last-modified', 'location', 'max-forwards', 'proxy-authorization',
  1180. 'referer', 'retry-after', 'user-agent'
  1181. ];
  1182. /**
  1183. * Parse headers into an object
  1184. *
  1185. * ```
  1186. * Date: Wed, 27 Aug 2014 08:58:49 GMT
  1187. * Content-Type: application/json
  1188. * Connection: keep-alive
  1189. * Transfer-Encoding: chunked
  1190. * ```
  1191. *
  1192. * @param {String} headers Headers needing to be parsed
  1193. * @returns {Object} Headers parsed into an object
  1194. */
  1195. module.exports = function parseHeaders(headers) {
  1196. var parsed = {};
  1197. var key;
  1198. var val;
  1199. var i;
  1200. if (!headers) { return parsed; }
  1201. utils.forEach(headers.split('\n'), function parser(line) {
  1202. i = line.indexOf(':');
  1203. key = utils.trim(line.substr(0, i)).toLowerCase();
  1204. val = utils.trim(line.substr(i + 1));
  1205. if (key) {
  1206. if (parsed[key] && ignoreDuplicateOf.indexOf(key) >= 0) {
  1207. return;
  1208. }
  1209. if (key === 'set-cookie') {
  1210. parsed[key] = (parsed[key] ? parsed[key] : []).concat([val]);
  1211. } else {
  1212. parsed[key] = parsed[key] ? parsed[key] + ', ' + val : val;
  1213. }
  1214. }
  1215. });
  1216. return parsed;
  1217. };
  1218. /***/ }),
  1219. /***/ "./node_modules/axios/lib/helpers/spread.js":
  1220. /*!**************************************************!*\
  1221. !*** ./node_modules/axios/lib/helpers/spread.js ***!
  1222. \**************************************************/
  1223. /*! no static exports found */
  1224. /***/ (function(module, exports, __webpack_require__) {
  1225. "use strict";
  1226. /**
  1227. * Syntactic sugar for invoking a function and expanding an array for arguments.
  1228. *
  1229. * Common use case would be to use `Function.prototype.apply`.
  1230. *
  1231. * ```js
  1232. * function f(x, y, z) {}
  1233. * var args = [1, 2, 3];
  1234. * f.apply(null, args);
  1235. * ```
  1236. *
  1237. * With `spread` this example can be re-written.
  1238. *
  1239. * ```js
  1240. * spread(function(x, y, z) {})([1, 2, 3]);
  1241. * ```
  1242. *
  1243. * @param {Function} callback
  1244. * @returns {Function}
  1245. */
  1246. module.exports = function spread(callback) {
  1247. return function wrap(arr) {
  1248. return callback.apply(null, arr);
  1249. };
  1250. };
  1251. /***/ }),
  1252. /***/ "./node_modules/axios/lib/utils.js":
  1253. /*!*****************************************!*\
  1254. !*** ./node_modules/axios/lib/utils.js ***!
  1255. \*****************************************/
  1256. /*! no static exports found */
  1257. /***/ (function(module, exports, __webpack_require__) {
  1258. "use strict";
  1259. var bind = __webpack_require__(/*! ./helpers/bind */ "./node_modules/axios/lib/helpers/bind.js");
  1260. /*global toString:true*/
  1261. // utils is a library of generic helper functions non-specific to axios
  1262. var toString = Object.prototype.toString;
  1263. /**
  1264. * Determine if a value is an Array
  1265. *
  1266. * @param {Object} val The value to test
  1267. * @returns {boolean} True if value is an Array, otherwise false
  1268. */
  1269. function isArray(val) {
  1270. return toString.call(val) === '[object Array]';
  1271. }
  1272. /**
  1273. * Determine if a value is undefined
  1274. *
  1275. * @param {Object} val The value to test
  1276. * @returns {boolean} True if the value is undefined, otherwise false
  1277. */
  1278. function isUndefined(val) {
  1279. return typeof val === 'undefined';
  1280. }
  1281. /**
  1282. * Determine if a value is a Buffer
  1283. *
  1284. * @param {Object} val The value to test
  1285. * @returns {boolean} True if value is a Buffer, otherwise false
  1286. */
  1287. function isBuffer(val) {
  1288. return val !== null && !isUndefined(val) && val.constructor !== null && !isUndefined(val.constructor)
  1289. && typeof val.constructor.isBuffer === 'function' && val.constructor.isBuffer(val);
  1290. }
  1291. /**
  1292. * Determine if a value is an ArrayBuffer
  1293. *
  1294. * @param {Object} val The value to test
  1295. * @returns {boolean} True if value is an ArrayBuffer, otherwise false
  1296. */
  1297. function isArrayBuffer(val) {
  1298. return toString.call(val) === '[object ArrayBuffer]';
  1299. }
  1300. /**
  1301. * Determine if a value is a FormData
  1302. *
  1303. * @param {Object} val The value to test
  1304. * @returns {boolean} True if value is an FormData, otherwise false
  1305. */
  1306. function isFormData(val) {
  1307. return (typeof FormData !== 'undefined') && (val instanceof FormData);
  1308. }
  1309. /**
  1310. * Determine if a value is a view on an ArrayBuffer
  1311. *
  1312. * @param {Object} val The value to test
  1313. * @returns {boolean} True if value is a view on an ArrayBuffer, otherwise false
  1314. */
  1315. function isArrayBufferView(val) {
  1316. var result;
  1317. if ((typeof ArrayBuffer !== 'undefined') && (ArrayBuffer.isView)) {
  1318. result = ArrayBuffer.isView(val);
  1319. } else {
  1320. result = (val) && (val.buffer) && (val.buffer instanceof ArrayBuffer);
  1321. }
  1322. return result;
  1323. }
  1324. /**
  1325. * Determine if a value is a String
  1326. *
  1327. * @param {Object} val The value to test
  1328. * @returns {boolean} True if value is a String, otherwise false
  1329. */
  1330. function isString(val) {
  1331. return typeof val === 'string';
  1332. }
  1333. /**
  1334. * Determine if a value is a Number
  1335. *
  1336. * @param {Object} val The value to test
  1337. * @returns {boolean} True if value is a Number, otherwise false
  1338. */
  1339. function isNumber(val) {
  1340. return typeof val === 'number';
  1341. }
  1342. /**
  1343. * Determine if a value is an Object
  1344. *
  1345. * @param {Object} val The value to test
  1346. * @returns {boolean} True if value is an Object, otherwise false
  1347. */
  1348. function isObject(val) {
  1349. return val !== null && typeof val === 'object';
  1350. }
  1351. /**
  1352. * Determine if a value is a Date
  1353. *
  1354. * @param {Object} val The value to test
  1355. * @returns {boolean} True if value is a Date, otherwise false
  1356. */
  1357. function isDate(val) {
  1358. return toString.call(val) === '[object Date]';
  1359. }
  1360. /**
  1361. * Determine if a value is a File
  1362. *
  1363. * @param {Object} val The value to test
  1364. * @returns {boolean} True if value is a File, otherwise false
  1365. */
  1366. function isFile(val) {
  1367. return toString.call(val) === '[object File]';
  1368. }
  1369. /**
  1370. * Determine if a value is a Blob
  1371. *
  1372. * @param {Object} val The value to test
  1373. * @returns {boolean} True if value is a Blob, otherwise false
  1374. */
  1375. function isBlob(val) {
  1376. return toString.call(val) === '[object Blob]';
  1377. }
  1378. /**
  1379. * Determine if a value is a Function
  1380. *
  1381. * @param {Object} val The value to test
  1382. * @returns {boolean} True if value is a Function, otherwise false
  1383. */
  1384. function isFunction(val) {
  1385. return toString.call(val) === '[object Function]';
  1386. }
  1387. /**
  1388. * Determine if a value is a Stream
  1389. *
  1390. * @param {Object} val The value to test
  1391. * @returns {boolean} True if value is a Stream, otherwise false
  1392. */
  1393. function isStream(val) {
  1394. return isObject(val) && isFunction(val.pipe);
  1395. }
  1396. /**
  1397. * Determine if a value is a URLSearchParams object
  1398. *
  1399. * @param {Object} val The value to test
  1400. * @returns {boolean} True if value is a URLSearchParams object, otherwise false
  1401. */
  1402. function isURLSearchParams(val) {
  1403. return typeof URLSearchParams !== 'undefined' && val instanceof URLSearchParams;
  1404. }
  1405. /**
  1406. * Trim excess whitespace off the beginning and end of a string
  1407. *
  1408. * @param {String} str The String to trim
  1409. * @returns {String} The String freed of excess whitespace
  1410. */
  1411. function trim(str) {
  1412. return str.replace(/^\s*/, '').replace(/\s*$/, '');
  1413. }
  1414. /**
  1415. * Determine if we're running in a standard browser environment
  1416. *
  1417. * This allows axios to run in a web worker, and react-native.
  1418. * Both environments support XMLHttpRequest, but not fully standard globals.
  1419. *
  1420. * web workers:
  1421. * typeof window -> undefined
  1422. * typeof document -> undefined
  1423. *
  1424. * react-native:
  1425. * navigator.product -> 'ReactNative'
  1426. * nativescript
  1427. * navigator.product -> 'NativeScript' or 'NS'
  1428. */
  1429. function isStandardBrowserEnv() {
  1430. if (typeof navigator !== 'undefined' && (navigator.product === 'ReactNative' ||
  1431. navigator.product === 'NativeScript' ||
  1432. navigator.product === 'NS')) {
  1433. return false;
  1434. }
  1435. return (
  1436. typeof window !== 'undefined' &&
  1437. typeof document !== 'undefined'
  1438. );
  1439. }
  1440. /**
  1441. * Iterate over an Array or an Object invoking a function for each item.
  1442. *
  1443. * If `obj` is an Array callback will be called passing
  1444. * the value, index, and complete array for each item.
  1445. *
  1446. * If 'obj' is an Object callback will be called passing
  1447. * the value, key, and complete object for each property.
  1448. *
  1449. * @param {Object|Array} obj The object to iterate
  1450. * @param {Function} fn The callback to invoke for each item
  1451. */
  1452. function forEach(obj, fn) {
  1453. // Don't bother if no value provided
  1454. if (obj === null || typeof obj === 'undefined') {
  1455. return;
  1456. }
  1457. // Force an array if not already something iterable
  1458. if (typeof obj !== 'object') {
  1459. /*eslint no-param-reassign:0*/
  1460. obj = [obj];
  1461. }
  1462. if (isArray(obj)) {
  1463. // Iterate over array values
  1464. for (var i = 0, l = obj.length; i < l; i++) {
  1465. fn.call(null, obj[i], i, obj);
  1466. }
  1467. } else {
  1468. // Iterate over object keys
  1469. for (var key in obj) {
  1470. if (Object.prototype.hasOwnProperty.call(obj, key)) {
  1471. fn.call(null, obj[key], key, obj);
  1472. }
  1473. }
  1474. }
  1475. }
  1476. /**
  1477. * Accepts varargs expecting each argument to be an object, then
  1478. * immutably merges the properties of each object and returns result.
  1479. *
  1480. * When multiple objects contain the same key the later object in
  1481. * the arguments list will take precedence.
  1482. *
  1483. * Example:
  1484. *
  1485. * ```js
  1486. * var result = merge({foo: 123}, {foo: 456});
  1487. * console.log(result.foo); // outputs 456
  1488. * ```
  1489. *
  1490. * @param {Object} obj1 Object to merge
  1491. * @returns {Object} Result of all merge properties
  1492. */
  1493. function merge(/* obj1, obj2, obj3, ... */) {
  1494. var result = {};
  1495. function assignValue(val, key) {
  1496. if (typeof result[key] === 'object' && typeof val === 'object') {
  1497. result[key] = merge(result[key], val);
  1498. } else {
  1499. result[key] = val;
  1500. }
  1501. }
  1502. for (var i = 0, l = arguments.length; i < l; i++) {
  1503. forEach(arguments[i], assignValue);
  1504. }
  1505. return result;
  1506. }
  1507. /**
  1508. * Function equal to merge with the difference being that no reference
  1509. * to original objects is kept.
  1510. *
  1511. * @see merge
  1512. * @param {Object} obj1 Object to merge
  1513. * @returns {Object} Result of all merge properties
  1514. */
  1515. function deepMerge(/* obj1, obj2, obj3, ... */) {
  1516. var result = {};
  1517. function assignValue(val, key) {
  1518. if (typeof result[key] === 'object' && typeof val === 'object') {
  1519. result[key] = deepMerge(result[key], val);
  1520. } else if (typeof val === 'object') {
  1521. result[key] = deepMerge({}, val);
  1522. } else {
  1523. result[key] = val;
  1524. }
  1525. }
  1526. for (var i = 0, l = arguments.length; i < l; i++) {
  1527. forEach(arguments[i], assignValue);
  1528. }
  1529. return result;
  1530. }
  1531. /**
  1532. * Extends object a by mutably adding to it the properties of object b.
  1533. *
  1534. * @param {Object} a The object to be extended
  1535. * @param {Object} b The object to copy properties from
  1536. * @param {Object} thisArg The object to bind function to
  1537. * @return {Object} The resulting value of object a
  1538. */
  1539. function extend(a, b, thisArg) {
  1540. forEach(b, function assignValue(val, key) {
  1541. if (thisArg && typeof val === 'function') {
  1542. a[key] = bind(val, thisArg);
  1543. } else {
  1544. a[key] = val;
  1545. }
  1546. });
  1547. return a;
  1548. }
  1549. module.exports = {
  1550. isArray: isArray,
  1551. isArrayBuffer: isArrayBuffer,
  1552. isBuffer: isBuffer,
  1553. isFormData: isFormData,
  1554. isArrayBufferView: isArrayBufferView,
  1555. isString: isString,
  1556. isNumber: isNumber,
  1557. isObject: isObject,
  1558. isUndefined: isUndefined,
  1559. isDate: isDate,
  1560. isFile: isFile,
  1561. isBlob: isBlob,
  1562. isFunction: isFunction,
  1563. isStream: isStream,
  1564. isURLSearchParams: isURLSearchParams,
  1565. isStandardBrowserEnv: isStandardBrowserEnv,
  1566. forEach: forEach,
  1567. merge: merge,
  1568. deepMerge: deepMerge,
  1569. extend: extend,
  1570. trim: trim
  1571. };
  1572. /***/ }),
  1573. /***/ "./node_modules/lodash/lodash.js":
  1574. /*!***************************************!*\
  1575. !*** ./node_modules/lodash/lodash.js ***!
  1576. \***************************************/
  1577. /*! no static exports found */
  1578. /***/ (function(module, exports, __webpack_require__) {
  1579. /* WEBPACK VAR INJECTION */(function(global, module) {var __WEBPACK_AMD_DEFINE_RESULT__;/**
  1580. * @license
  1581. * Lodash <https://lodash.com/>
  1582. * Copyright OpenJS Foundation and other contributors <https://openjsf.org/>
  1583. * Released under MIT license <https://lodash.com/license>
  1584. * Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
  1585. * Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
  1586. */
  1587. ;(function() {
  1588. /** Used as a safe reference for `undefined` in pre-ES5 environments. */
  1589. var undefined;
  1590. /** Used as the semantic version number. */
  1591. var VERSION = '4.17.20';
  1592. /** Used as the size to enable large array optimizations. */
  1593. var LARGE_ARRAY_SIZE = 200;
  1594. /** Error message constants. */
  1595. var CORE_ERROR_TEXT = 'Unsupported core-js use. Try https://npms.io/search?q=ponyfill.',
  1596. FUNC_ERROR_TEXT = 'Expected a function';
  1597. /** Used to stand-in for `undefined` hash values. */
  1598. var HASH_UNDEFINED = '__lodash_hash_undefined__';
  1599. /** Used as the maximum memoize cache size. */
  1600. var MAX_MEMOIZE_SIZE = 500;
  1601. /** Used as the internal argument placeholder. */
  1602. var PLACEHOLDER = '__lodash_placeholder__';
  1603. /** Used to compose bitmasks for cloning. */
  1604. var CLONE_DEEP_FLAG = 1,
  1605. CLONE_FLAT_FLAG = 2,
  1606. CLONE_SYMBOLS_FLAG = 4;
  1607. /** Used to compose bitmasks for value comparisons. */
  1608. var COMPARE_PARTIAL_FLAG = 1,
  1609. COMPARE_UNORDERED_FLAG = 2;
  1610. /** Used to compose bitmasks for function metadata. */
  1611. var WRAP_BIND_FLAG = 1,
  1612. WRAP_BIND_KEY_FLAG = 2,
  1613. WRAP_CURRY_BOUND_FLAG = 4,
  1614. WRAP_CURRY_FLAG = 8,
  1615. WRAP_CURRY_RIGHT_FLAG = 16,
  1616. WRAP_PARTIAL_FLAG = 32,
  1617. WRAP_PARTIAL_RIGHT_FLAG = 64,
  1618. WRAP_ARY_FLAG = 128,
  1619. WRAP_REARG_FLAG = 256,
  1620. WRAP_FLIP_FLAG = 512;
  1621. /** Used as default options for `_.truncate`. */
  1622. var DEFAULT_TRUNC_LENGTH = 30,
  1623. DEFAULT_TRUNC_OMISSION = '...';
  1624. /** Used to detect hot functions by number of calls within a span of milliseconds. */
  1625. var HOT_COUNT = 800,
  1626. HOT_SPAN = 16;
  1627. /** Used to indicate the type of lazy iteratees. */
  1628. var LAZY_FILTER_FLAG = 1,
  1629. LAZY_MAP_FLAG = 2,
  1630. LAZY_WHILE_FLAG = 3;
  1631. /** Used as references for various `Number` constants. */
  1632. var INFINITY = 1 / 0,
  1633. MAX_SAFE_INTEGER = 9007199254740991,
  1634. MAX_INTEGER = 1.7976931348623157e+308,
  1635. NAN = 0 / 0;
  1636. /** Used as references for the maximum length and index of an array. */
  1637. var MAX_ARRAY_LENGTH = 4294967295,
  1638. MAX_ARRAY_INDEX = MAX_ARRAY_LENGTH - 1,
  1639. HALF_MAX_ARRAY_LENGTH = MAX_ARRAY_LENGTH >>> 1;
  1640. /** Used to associate wrap methods with their bit flags. */
  1641. var wrapFlags = [
  1642. ['ary', WRAP_ARY_FLAG],
  1643. ['bind', WRAP_BIND_FLAG],
  1644. ['bindKey', WRAP_BIND_KEY_FLAG],
  1645. ['curry', WRAP_CURRY_FLAG],
  1646. ['curryRight', WRAP_CURRY_RIGHT_FLAG],
  1647. ['flip', WRAP_FLIP_FLAG],
  1648. ['partial', WRAP_PARTIAL_FLAG],
  1649. ['partialRight', WRAP_PARTIAL_RIGHT_FLAG],
  1650. ['rearg', WRAP_REARG_FLAG]
  1651. ];
  1652. /** `Object#toString` result references. */
  1653. var argsTag = '[object Arguments]',
  1654. arrayTag = '[object Array]',
  1655. asyncTag = '[object AsyncFunction]',
  1656. boolTag = '[object Boolean]',
  1657. dateTag = '[object Date]',
  1658. domExcTag = '[object DOMException]',
  1659. errorTag = '[object Error]',
  1660. funcTag = '[object Function]',
  1661. genTag = '[object GeneratorFunction]',
  1662. mapTag = '[object Map]',
  1663. numberTag = '[object Number]',
  1664. nullTag = '[object Null]',
  1665. objectTag = '[object Object]',
  1666. promiseTag = '[object Promise]',
  1667. proxyTag = '[object Proxy]',
  1668. regexpTag = '[object RegExp]',
  1669. setTag = '[object Set]',
  1670. stringTag = '[object String]',
  1671. symbolTag = '[object Symbol]',
  1672. undefinedTag = '[object Undefined]',
  1673. weakMapTag = '[object WeakMap]',
  1674. weakSetTag = '[object WeakSet]';
  1675. var arrayBufferTag = '[object ArrayBuffer]',
  1676. dataViewTag = '[object DataView]',
  1677. float32Tag = '[object Float32Array]',
  1678. float64Tag = '[object Float64Array]',
  1679. int8Tag = '[object Int8Array]',
  1680. int16Tag = '[object Int16Array]',
  1681. int32Tag = '[object Int32Array]',
  1682. uint8Tag = '[object Uint8Array]',
  1683. uint8ClampedTag = '[object Uint8ClampedArray]',
  1684. uint16Tag = '[object Uint16Array]',
  1685. uint32Tag = '[object Uint32Array]';
  1686. /** Used to match empty string literals in compiled template source. */
  1687. var reEmptyStringLeading = /\b__p \+= '';/g,
  1688. reEmptyStringMiddle = /\b(__p \+=) '' \+/g,
  1689. reEmptyStringTrailing = /(__e\(.*?\)|\b__t\)) \+\n'';/g;
  1690. /** Used to match HTML entities and HTML characters. */
  1691. var reEscapedHtml = /&(?:amp|lt|gt|quot|#39);/g,
  1692. reUnescapedHtml = /[&<>"']/g,
  1693. reHasEscapedHtml = RegExp(reEscapedHtml.source),
  1694. reHasUnescapedHtml = RegExp(reUnescapedHtml.source);
  1695. /** Used to match template delimiters. */
  1696. var reEscape = /<%-([\s\S]+?)%>/g,
  1697. reEvaluate = /<%([\s\S]+?)%>/g,
  1698. reInterpolate = /<%=([\s\S]+?)%>/g;
  1699. /** Used to match property names within property paths. */
  1700. var reIsDeepProp = /\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,
  1701. reIsPlainProp = /^\w*$/,
  1702. rePropName = /[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g;
  1703. /**
  1704. * Used to match `RegExp`
  1705. * [syntax characters](http://ecma-international.org/ecma-262/7.0/#sec-patterns).
  1706. */
  1707. var reRegExpChar = /[\\^$.*+?()[\]{}|]/g,
  1708. reHasRegExpChar = RegExp(reRegExpChar.source);
  1709. /** Used to match leading and trailing whitespace. */
  1710. var reTrim = /^\s+|\s+$/g,
  1711. reTrimStart = /^\s+/,
  1712. reTrimEnd = /\s+$/;
  1713. /** Used to match wrap detail comments. */
  1714. var reWrapComment = /\{(?:\n\/\* \[wrapped with .+\] \*\/)?\n?/,
  1715. reWrapDetails = /\{\n\/\* \[wrapped with (.+)\] \*/,
  1716. reSplitDetails = /,? & /;
  1717. /** Used to match words composed of alphanumeric characters. */
  1718. var reAsciiWord = /[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g;
  1719. /** Used to match backslashes in property paths. */
  1720. var reEscapeChar = /\\(\\)?/g;
  1721. /**
  1722. * Used to match
  1723. * [ES template delimiters](http://ecma-international.org/ecma-262/7.0/#sec-template-literal-lexical-components).
  1724. */
  1725. var reEsTemplate = /\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g;
  1726. /** Used to match `RegExp` flags from their coerced string values. */
  1727. var reFlags = /\w*$/;
  1728. /** Used to detect bad signed hexadecimal string values. */
  1729. var reIsBadHex = /^[-+]0x[0-9a-f]+$/i;
  1730. /** Used to detect binary string values. */
  1731. var reIsBinary = /^0b[01]+$/i;
  1732. /** Used to detect host constructors (Safari). */
  1733. var reIsHostCtor = /^\[object .+?Constructor\]$/;
  1734. /** Used to detect octal string values. */
  1735. var reIsOctal = /^0o[0-7]+$/i;
  1736. /** Used to detect unsigned integer values. */
  1737. var reIsUint = /^(?:0|[1-9]\d*)$/;
  1738. /** Used to match Latin Unicode letters (excluding mathematical operators). */
  1739. var reLatin = /[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g;
  1740. /** Used to ensure capturing order of template delimiters. */
  1741. var reNoMatch = /($^)/;
  1742. /** Used to match unescaped characters in compiled string literals. */
  1743. var reUnescapedString = /['\n\r\u2028\u2029\\]/g;
  1744. /** Used to compose unicode character classes. */
  1745. var rsAstralRange = '\\ud800-\\udfff',
  1746. rsComboMarksRange = '\\u0300-\\u036f',
  1747. reComboHalfMarksRange = '\\ufe20-\\ufe2f',
  1748. rsComboSymbolsRange = '\\u20d0-\\u20ff',
  1749. rsComboRange = rsComboMarksRange + reComboHalfMarksRange + rsComboSymbolsRange,
  1750. rsDingbatRange = '\\u2700-\\u27bf',
  1751. rsLowerRange = 'a-z\\xdf-\\xf6\\xf8-\\xff',
  1752. rsMathOpRange = '\\xac\\xb1\\xd7\\xf7',
  1753. rsNonCharRange = '\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf',
  1754. rsPunctuationRange = '\\u2000-\\u206f',
  1755. 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',
  1756. rsUpperRange = 'A-Z\\xc0-\\xd6\\xd8-\\xde',
  1757. rsVarRange = '\\ufe0e\\ufe0f',
  1758. rsBreakRange = rsMathOpRange + rsNonCharRange + rsPunctuationRange + rsSpaceRange;
  1759. /** Used to compose unicode capture groups. */
  1760. var rsApos = "['\u2019]",
  1761. rsAstral = '[' + rsAstralRange + ']',
  1762. rsBreak = '[' + rsBreakRange + ']',
  1763. rsCombo = '[' + rsComboRange + ']',
  1764. rsDigits = '\\d+',
  1765. rsDingbat = '[' + rsDingbatRange + ']',
  1766. rsLower = '[' + rsLowerRange + ']',
  1767. rsMisc = '[^' + rsAstralRange + rsBreakRange + rsDigits + rsDingbatRange + rsLowerRange + rsUpperRange + ']',
  1768. rsFitz = '\\ud83c[\\udffb-\\udfff]',
  1769. rsModifier = '(?:' + rsCombo + '|' + rsFitz + ')',
  1770. rsNonAstral = '[^' + rsAstralRange + ']',
  1771. rsRegional = '(?:\\ud83c[\\udde6-\\uddff]){2}',
  1772. rsSurrPair = '[\\ud800-\\udbff][\\udc00-\\udfff]',
  1773. rsUpper = '[' + rsUpperRange + ']',
  1774. rsZWJ = '\\u200d';
  1775. /** Used to compose unicode regexes. */
  1776. var rsMiscLower = '(?:' + rsLower + '|' + rsMisc + ')',
  1777. rsMiscUpper = '(?:' + rsUpper + '|' + rsMisc + ')',
  1778. rsOptContrLower = '(?:' + rsApos + '(?:d|ll|m|re|s|t|ve))?',
  1779. rsOptContrUpper = '(?:' + rsApos + '(?:D|LL|M|RE|S|T|VE))?',
  1780. reOptMod = rsModifier + '?',
  1781. rsOptVar = '[' + rsVarRange + ']?',
  1782. rsOptJoin = '(?:' + rsZWJ + '(?:' + [rsNonAstral, rsRegional, rsSurrPair].join('|') + ')' + rsOptVar + reOptMod + ')*',
  1783. rsOrdLower = '\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])',
  1784. rsOrdUpper = '\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])',
  1785. rsSeq = rsOptVar + reOptMod + rsOptJoin,
  1786. rsEmoji = '(?:' + [rsDingbat, rsRegional, rsSurrPair].join('|') + ')' + rsSeq,
  1787. rsSymbol = '(?:' + [rsNonAstral + rsCombo + '?', rsCombo, rsRegional, rsSurrPair, rsAstral].join('|') + ')';
  1788. /** Used to match apostrophes. */
  1789. var reApos = RegExp(rsApos, 'g');
  1790. /**
  1791. * Used to match [combining diacritical marks](https://en.wikipedia.org/wiki/Combining_Diacritical_Marks) and
  1792. * [combining diacritical marks for symbols](https://en.wikipedia.org/wiki/Combining_Diacritical_Marks_for_Symbols).
  1793. */
  1794. var reComboMark = RegExp(rsCombo, 'g');
  1795. /** Used to match [string symbols](https://mathiasbynens.be/notes/javascript-unicode). */
  1796. var reUnicode = RegExp(rsFitz + '(?=' + rsFitz + ')|' + rsSymbol + rsSeq, 'g');
  1797. /** Used to match complex or compound words. */
  1798. var reUnicodeWord = RegExp([
  1799. rsUpper + '?' + rsLower + '+' + rsOptContrLower + '(?=' + [rsBreak, rsUpper, '$'].join('|') + ')',
  1800. rsMiscUpper + '+' + rsOptContrUpper + '(?=' + [rsBreak, rsUpper + rsMiscLower, '$'].join('|') + ')',
  1801. rsUpper + '?' + rsMiscLower + '+' + rsOptContrLower,
  1802. rsUpper + '+' + rsOptContrUpper,
  1803. rsOrdUpper,
  1804. rsOrdLower,
  1805. rsDigits,
  1806. rsEmoji
  1807. ].join('|'), 'g');
  1808. /** 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/). */
  1809. var reHasUnicode = RegExp('[' + rsZWJ + rsAstralRange + rsComboRange + rsVarRange + ']');
  1810. /** Used to detect strings that need a more robust regexp to match words. */
  1811. 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 ]/;
  1812. /** Used to assign default `context` object properties. */
  1813. var contextProps = [
  1814. 'Array', 'Buffer', 'DataView', 'Date', 'Error', 'Float32Array', 'Float64Array',
  1815. 'Function', 'Int8Array', 'Int16Array', 'Int32Array', 'Map', 'Math', 'Object',
  1816. 'Promise', 'RegExp', 'Set', 'String', 'Symbol', 'TypeError', 'Uint8Array',
  1817. 'Uint8ClampedArray', 'Uint16Array', 'Uint32Array', 'WeakMap',
  1818. '_', 'clearTimeout', 'isFinite', 'parseInt', 'setTimeout'
  1819. ];
  1820. /** Used to make template sourceURLs easier to identify. */
  1821. var templateCounter = -1;
  1822. /** Used to identify `toStringTag` values of typed arrays. */
  1823. var typedArrayTags = {};
  1824. typedArrayTags[float32Tag] = typedArrayTags[float64Tag] =
  1825. typedArrayTags[int8Tag] = typedArrayTags[int16Tag] =
  1826. typedArrayTags[int32Tag] = typedArrayTags[uint8Tag] =
  1827. typedArrayTags[uint8ClampedTag] = typedArrayTags[uint16Tag] =
  1828. typedArrayTags[uint32Tag] = true;
  1829. typedArrayTags[argsTag] = typedArrayTags[arrayTag] =
  1830. typedArrayTags[arrayBufferTag] = typedArrayTags[boolTag] =
  1831. typedArrayTags[dataViewTag] = typedArrayTags[dateTag] =
  1832. typedArrayTags[errorTag] = typedArrayTags[funcTag] =
  1833. typedArrayTags[mapTag] = typedArrayTags[numberTag] =
  1834. typedArrayTags[objectTag] = typedArrayTags[regexpTag] =
  1835. typedArrayTags[setTag] = typedArrayTags[stringTag] =
  1836. typedArrayTags[weakMapTag] = false;
  1837. /** Used to identify `toStringTag` values supported by `_.clone`. */
  1838. var cloneableTags = {};
  1839. cloneableTags[argsTag] = cloneableTags[arrayTag] =
  1840. cloneableTags[arrayBufferTag] = cloneableTags[dataViewTag] =
  1841. cloneableTags[boolTag] = cloneableTags[dateTag] =
  1842. cloneableTags[float32Tag] = cloneableTags[float64Tag] =
  1843. cloneableTags[int8Tag] = cloneableTags[int16Tag] =
  1844. cloneableTags[int32Tag] = cloneableTags[mapTag] =
  1845. cloneableTags[numberTag] = cloneableTags[objectTag] =
  1846. cloneableTags[regexpTag] = cloneableTags[setTag] =
  1847. cloneableTags[stringTag] = cloneableTags[symbolTag] =
  1848. cloneableTags[uint8Tag] = cloneableTags[uint8ClampedTag] =
  1849. cloneableTags[uint16Tag] = cloneableTags[uint32Tag] = true;
  1850. cloneableTags[errorTag] = cloneableTags[funcTag] =
  1851. cloneableTags[weakMapTag] = false;
  1852. /** Used to map Latin Unicode letters to basic Latin letters. */
  1853. var deburredLetters = {
  1854. // Latin-1 Supplement block.
  1855. '\xc0': 'A', '\xc1': 'A', '\xc2': 'A', '\xc3': 'A', '\xc4': 'A', '\xc5': 'A',
  1856. '\xe0': 'a', '\xe1': 'a', '\xe2': 'a', '\xe3': 'a', '\xe4': 'a', '\xe5': 'a',
  1857. '\xc7': 'C', '\xe7': 'c',
  1858. '\xd0': 'D', '\xf0': 'd',
  1859. '\xc8': 'E', '\xc9': 'E', '\xca': 'E', '\xcb': 'E',
  1860. '\xe8': 'e', '\xe9': 'e', '\xea': 'e', '\xeb': 'e',
  1861. '\xcc': 'I', '\xcd': 'I', '\xce': 'I', '\xcf': 'I',
  1862. '\xec': 'i', '\xed': 'i', '\xee': 'i', '\xef': 'i',
  1863. '\xd1': 'N', '\xf1': 'n',
  1864. '\xd2': 'O', '\xd3': 'O', '\xd4': 'O', '\xd5': 'O', '\xd6': 'O', '\xd8': 'O',
  1865. '\xf2': 'o', '\xf3': 'o', '\xf4': 'o', '\xf5': 'o', '\xf6': 'o', '\xf8': 'o',
  1866. '\xd9': 'U', '\xda': 'U', '\xdb': 'U', '\xdc': 'U',
  1867. '\xf9': 'u', '\xfa': 'u', '\xfb': 'u', '\xfc': 'u',
  1868. '\xdd': 'Y', '\xfd': 'y', '\xff': 'y',
  1869. '\xc6': 'Ae', '\xe6': 'ae',
  1870. '\xde': 'Th', '\xfe': 'th',
  1871. '\xdf': 'ss',
  1872. // Latin Extended-A block.
  1873. '\u0100': 'A', '\u0102': 'A', '\u0104': 'A',
  1874. '\u0101': 'a', '\u0103': 'a', '\u0105': 'a',
  1875. '\u0106': 'C', '\u0108': 'C', '\u010a': 'C', '\u010c': 'C',
  1876. '\u0107': 'c', '\u0109': 'c', '\u010b': 'c', '\u010d': 'c',
  1877. '\u010e': 'D', '\u0110': 'D', '\u010f': 'd', '\u0111': 'd',
  1878. '\u0112': 'E', '\u0114': 'E', '\u0116': 'E', '\u0118': 'E', '\u011a': 'E',
  1879. '\u0113': 'e', '\u0115': 'e', '\u0117': 'e', '\u0119': 'e', '\u011b': 'e',
  1880. '\u011c': 'G', '\u011e': 'G', '\u0120': 'G', '\u0122': 'G',
  1881. '\u011d': 'g', '\u011f': 'g', '\u0121': 'g', '\u0123': 'g',
  1882. '\u0124': 'H', '\u0126': 'H', '\u0125': 'h', '\u0127': 'h',
  1883. '\u0128': 'I', '\u012a': 'I', '\u012c': 'I', '\u012e': 'I', '\u0130': 'I',
  1884. '\u0129': 'i', '\u012b': 'i', '\u012d': 'i', '\u012f': 'i', '\u0131': 'i',
  1885. '\u0134': 'J', '\u0135': 'j',
  1886. '\u0136': 'K', '\u0137': 'k', '\u0138': 'k',
  1887. '\u0139': 'L', '\u013b': 'L', '\u013d': 'L', '\u013f': 'L', '\u0141': 'L',
  1888. '\u013a': 'l', '\u013c': 'l', '\u013e': 'l', '\u0140': 'l', '\u0142': 'l',
  1889. '\u0143': 'N', '\u0145': 'N', '\u0147': 'N', '\u014a': 'N',
  1890. '\u0144': 'n', '\u0146': 'n', '\u0148': 'n', '\u014b': 'n',
  1891. '\u014c': 'O', '\u014e': 'O', '\u0150': 'O',
  1892. '\u014d': 'o', '\u014f': 'o', '\u0151': 'o',
  1893. '\u0154': 'R', '\u0156': 'R', '\u0158': 'R',
  1894. '\u0155': 'r', '\u0157': 'r', '\u0159': 'r',
  1895. '\u015a': 'S', '\u015c': 'S', '\u015e': 'S', '\u0160': 'S',
  1896. '\u015b': 's', '\u015d': 's', '\u015f': 's', '\u0161': 's',
  1897. '\u0162': 'T', '\u0164': 'T', '\u0166': 'T',
  1898. '\u0163': 't', '\u0165': 't', '\u0167': 't',
  1899. '\u0168': 'U', '\u016a': 'U', '\u016c': 'U', '\u016e': 'U', '\u0170': 'U', '\u0172': 'U',
  1900. '\u0169': 'u', '\u016b': 'u', '\u016d': 'u', '\u016f': 'u', '\u0171': 'u', '\u0173': 'u',
  1901. '\u0174': 'W', '\u0175': 'w',
  1902. '\u0176': 'Y', '\u0177': 'y', '\u0178': 'Y',
  1903. '\u0179': 'Z', '\u017b': 'Z', '\u017d': 'Z',
  1904. '\u017a': 'z', '\u017c': 'z', '\u017e': 'z',
  1905. '\u0132': 'IJ', '\u0133': 'ij',
  1906. '\u0152': 'Oe', '\u0153': 'oe',
  1907. '\u0149': "'n", '\u017f': 's'
  1908. };
  1909. /** Used to map characters to HTML entities. */
  1910. var htmlEscapes = {
  1911. '&': '&amp;',
  1912. '<': '&lt;',
  1913. '>': '&gt;',
  1914. '"': '&quot;',
  1915. "'": '&#39;'
  1916. };
  1917. /** Used to map HTML entities to characters. */
  1918. var htmlUnescapes = {
  1919. '&amp;': '&',
  1920. '&lt;': '<',
  1921. '&gt;': '>',
  1922. '&quot;': '"',
  1923. '&#39;': "'"
  1924. };
  1925. /** Used to escape characters for inclusion in compiled string literals. */
  1926. var stringEscapes = {
  1927. '\\': '\\',
  1928. "'": "'",
  1929. '\n': 'n',
  1930. '\r': 'r',
  1931. '\u2028': 'u2028',
  1932. '\u2029': 'u2029'
  1933. };
  1934. /** Built-in method references without a dependency on `root`. */
  1935. var freeParseFloat = parseFloat,
  1936. freeParseInt = parseInt;
  1937. /** Detect free variable `global` from Node.js. */
  1938. var freeGlobal = typeof global == 'object' && global && global.Object === Object && global;
  1939. /** Detect free variable `self`. */
  1940. var freeSelf = typeof self == 'object' && self && self.Object === Object && self;
  1941. /** Used as a reference to the global object. */
  1942. var root = freeGlobal || freeSelf || Function('return this')();
  1943. /** Detect free variable `exports`. */
  1944. var freeExports = true && exports && !exports.nodeType && exports;
  1945. /** Detect free variable `module`. */
  1946. var freeModule = freeExports && typeof module == 'object' && module && !module.nodeType && module;
  1947. /** Detect the popular CommonJS extension `module.exports`. */
  1948. var moduleExports = freeModule && freeModule.exports === freeExports;
  1949. /** Detect free variable `process` from Node.js. */
  1950. var freeProcess = moduleExports && freeGlobal.process;
  1951. /** Used to access faster Node.js helpers. */
  1952. var nodeUtil = (function() {
  1953. try {
  1954. // Use `util.types` for Node.js 10+.
  1955. var types = freeModule && freeModule.require && freeModule.require('util').types;
  1956. if (types) {
  1957. return types;
  1958. }
  1959. // Legacy `process.binding('util')` for Node.js < 10.
  1960. return freeProcess && freeProcess.binding && freeProcess.binding('util');
  1961. } catch (e) {}
  1962. }());
  1963. /* Node.js helper references. */
  1964. var nodeIsArrayBuffer = nodeUtil && nodeUtil.isArrayBuffer,
  1965. nodeIsDate = nodeUtil && nodeUtil.isDate,
  1966. nodeIsMap = nodeUtil && nodeUtil.isMap,
  1967. nodeIsRegExp = nodeUtil && nodeUtil.isRegExp,
  1968. nodeIsSet = nodeUtil && nodeUtil.isSet,
  1969. nodeIsTypedArray = nodeUtil && nodeUtil.isTypedArray;
  1970. /*--------------------------------------------------------------------------*/
  1971. /**
  1972. * A faster alternative to `Function#apply`, this function invokes `func`
  1973. * with the `this` binding of `thisArg` and the arguments of `args`.
  1974. *
  1975. * @private
  1976. * @param {Function} func The function to invoke.
  1977. * @param {*} thisArg The `this` binding of `func`.
  1978. * @param {Array} args The arguments to invoke `func` with.
  1979. * @returns {*} Returns the result of `func`.
  1980. */
  1981. function apply(func, thisArg, args) {
  1982. switch (args.length) {
  1983. case 0: return func.call(thisArg);
  1984. case 1: return func.call(thisArg, args[0]);
  1985. case 2: return func.call(thisArg, args[0], args[1]);
  1986. case 3: return func.call(thisArg, args[0], args[1], args[2]);
  1987. }
  1988. return func.apply(thisArg, args);
  1989. }
  1990. /**
  1991. * A specialized version of `baseAggregator` for arrays.
  1992. *
  1993. * @private
  1994. * @param {Array} [array] The array to iterate over.
  1995. * @param {Function} setter The function to set `accumulator` values.
  1996. * @param {Function} iteratee The iteratee to transform keys.
  1997. * @param {Object} accumulator The initial aggregated object.
  1998. * @returns {Function} Returns `accumulator`.
  1999. */
  2000. function arrayAggregator(array, setter, iteratee, accumulator) {
  2001. var index = -1,
  2002. length = array == null ? 0 : array.length;
  2003. while (++index < length) {
  2004. var value = array[index];
  2005. setter(accumulator, value, iteratee(value), array);
  2006. }
  2007. return accumulator;
  2008. }
  2009. /**
  2010. * A specialized version of `_.forEach` for arrays without support for
  2011. * iteratee shorthands.
  2012. *
  2013. * @private
  2014. * @param {Array} [array] The array to iterate over.
  2015. * @param {Function} iteratee The function invoked per iteration.
  2016. * @returns {Array} Returns `array`.
  2017. */
  2018. function arrayEach(array, iteratee) {
  2019. var index = -1,
  2020. length = array == null ? 0 : array.length;
  2021. while (++index < length) {
  2022. if (iteratee(array[index], index, array) === false) {
  2023. break;
  2024. }
  2025. }
  2026. return array;
  2027. }
  2028. /**
  2029. * A specialized version of `_.forEachRight` for arrays without support for
  2030. * iteratee shorthands.
  2031. *
  2032. * @private
  2033. * @param {Array} [array] The array to iterate over.
  2034. * @param {Function} iteratee The function invoked per iteration.
  2035. * @returns {Array} Returns `array`.
  2036. */
  2037. function arrayEachRight(array, iteratee) {
  2038. var length = array == null ? 0 : array.length;
  2039. while (length--) {
  2040. if (iteratee(array[length], length, array) === false) {
  2041. break;
  2042. }
  2043. }
  2044. return array;
  2045. }
  2046. /**
  2047. * A specialized version of `_.every` for arrays without support for
  2048. * iteratee shorthands.
  2049. *
  2050. * @private
  2051. * @param {Array} [array] The array to iterate over.
  2052. * @param {Function} predicate The function invoked per iteration.
  2053. * @returns {boolean} Returns `true` if all elements pass the predicate check,
  2054. * else `false`.
  2055. */
  2056. function arrayEvery(array, predicate) {
  2057. var index = -1,
  2058. length = array == null ? 0 : array.length;
  2059. while (++index < length) {
  2060. if (!predicate(array[index], index, array)) {
  2061. return false;
  2062. }
  2063. }
  2064. return true;
  2065. }
  2066. /**
  2067. * A specialized version of `_.filter` for arrays without support for
  2068. * iteratee shorthands.
  2069. *
  2070. * @private
  2071. * @param {Array} [array] The array to iterate over.
  2072. * @param {Function} predicate The function invoked per iteration.
  2073. * @returns {Array} Returns the new filtered array.
  2074. */
  2075. function arrayFilter(array, predicate) {
  2076. var index = -1,
  2077. length = array == null ? 0 : array.length,
  2078. resIndex = 0,
  2079. result = [];
  2080. while (++index < length) {
  2081. var value = array[index];
  2082. if (predicate(value, index, array)) {
  2083. result[resIndex++] = value;
  2084. }
  2085. }
  2086. return result;
  2087. }
  2088. /**
  2089. * A specialized version of `_.includes` for arrays without support for
  2090. * specifying an index to search from.
  2091. *
  2092. * @private
  2093. * @param {Array} [array] The array to inspect.
  2094. * @param {*} target The value to search for.
  2095. * @returns {boolean} Returns `true` if `target` is found, else `false`.
  2096. */
  2097. function arrayIncludes(array, value) {
  2098. var length = array == null ? 0 : array.length;
  2099. return !!length && baseIndexOf(array, value, 0) > -1;
  2100. }
  2101. /**
  2102. * This function is like `arrayIncludes` except that it accepts a comparator.
  2103. *
  2104. * @private
  2105. * @param {Array} [array] The array to inspect.
  2106. * @param {*} target The value to search for.
  2107. * @param {Function} comparator The comparator invoked per element.
  2108. * @returns {boolean} Returns `true` if `target` is found, else `false`.
  2109. */
  2110. function arrayIncludesWith(array, value, comparator) {
  2111. var index = -1,
  2112. length = array == null ? 0 : array.length;
  2113. while (++index < length) {
  2114. if (comparator(value, array[index])) {
  2115. return true;
  2116. }
  2117. }
  2118. return false;
  2119. }
  2120. /**
  2121. * A specialized version of `_.map` for arrays without support for iteratee
  2122. * shorthands.
  2123. *
  2124. * @private
  2125. * @param {Array} [array] The array to iterate over.
  2126. * @param {Function} iteratee The function invoked per iteration.
  2127. * @returns {Array} Returns the new mapped array.
  2128. */
  2129. function arrayMap(array, iteratee) {
  2130. var index = -1,
  2131. length = array == null ? 0 : array.length,
  2132. result = Array(length);
  2133. while (++index < length) {
  2134. result[index] = iteratee(array[index], index, array);
  2135. }
  2136. return result;
  2137. }
  2138. /**
  2139. * Appends the elements of `values` to `array`.
  2140. *
  2141. * @private
  2142. * @param {Array} array The array to modify.
  2143. * @param {Array} values The values to append.
  2144. * @returns {Array} Returns `array`.
  2145. */
  2146. function arrayPush(array, values) {
  2147. var index = -1,
  2148. length = values.length,
  2149. offset = array.length;
  2150. while (++index < length) {
  2151. array[offset + index] = values[index];
  2152. }
  2153. return array;
  2154. }
  2155. /**
  2156. * A specialized version of `_.reduce` for arrays without support for
  2157. * iteratee shorthands.
  2158. *
  2159. * @private
  2160. * @param {Array} [array] The array to iterate over.
  2161. * @param {Function} iteratee The function invoked per iteration.
  2162. * @param {*} [accumulator] The initial value.
  2163. * @param {boolean} [initAccum] Specify using the first element of `array` as
  2164. * the initial value.
  2165. * @returns {*} Returns the accumulated value.
  2166. */
  2167. function arrayReduce(array, iteratee, accumulator, initAccum) {
  2168. var index = -1,
  2169. length = array == null ? 0 : array.length;
  2170. if (initAccum && length) {
  2171. accumulator = array[++index];
  2172. }
  2173. while (++index < length) {
  2174. accumulator = iteratee(accumulator, array[index], index, array);
  2175. }
  2176. return accumulator;
  2177. }
  2178. /**
  2179. * A specialized version of `_.reduceRight` for arrays without support for
  2180. * iteratee shorthands.
  2181. *
  2182. * @private
  2183. * @param {Array} [array] The array to iterate over.
  2184. * @param {Function} iteratee The function invoked per iteration.
  2185. * @param {*} [accumulator] The initial value.
  2186. * @param {boolean} [initAccum] Specify using the last element of `array` as
  2187. * the initial value.
  2188. * @returns {*} Returns the accumulated value.
  2189. */
  2190. function arrayReduceRight(array, iteratee, accumulator, initAccum) {
  2191. var length = array == null ? 0 : array.length;
  2192. if (initAccum && length) {
  2193. accumulator = array[--length];
  2194. }
  2195. while (length--) {
  2196. accumulator = iteratee(accumulator, array[length], length, array);
  2197. }
  2198. return accumulator;
  2199. }
  2200. /**
  2201. * A specialized version of `_.some` for arrays without support for iteratee
  2202. * shorthands.
  2203. *
  2204. * @private
  2205. * @param {Array} [array] The array to iterate over.
  2206. * @param {Function} predicate The function invoked per iteration.
  2207. * @returns {boolean} Returns `true` if any element passes the predicate check,
  2208. * else `false`.
  2209. */
  2210. function arraySome(array, predicate) {
  2211. var index = -1,
  2212. length = array == null ? 0 : array.length;
  2213. while (++index < length) {
  2214. if (predicate(array[index], index, array)) {
  2215. return true;
  2216. }
  2217. }
  2218. return false;
  2219. }
  2220. /**
  2221. * Gets the size of an ASCII `string`.
  2222. *
  2223. * @private
  2224. * @param {string} string The string inspect.
  2225. * @returns {number} Returns the string size.
  2226. */
  2227. var asciiSize = baseProperty('length');
  2228. /**
  2229. * Converts an ASCII `string` to an array.
  2230. *
  2231. * @private
  2232. * @param {string} string The string to convert.
  2233. * @returns {Array} Returns the converted array.
  2234. */
  2235. function asciiToArray(string) {
  2236. return string.split('');
  2237. }
  2238. /**
  2239. * Splits an ASCII `string` into an array of its words.
  2240. *
  2241. * @private
  2242. * @param {string} The string to inspect.
  2243. * @returns {Array} Returns the words of `string`.
  2244. */
  2245. function asciiWords(string) {
  2246. return string.match(reAsciiWord) || [];
  2247. }
  2248. /**
  2249. * The base implementation of methods like `_.findKey` and `_.findLastKey`,
  2250. * without support for iteratee shorthands, which iterates over `collection`
  2251. * using `eachFunc`.
  2252. *
  2253. * @private
  2254. * @param {Array|Object} collection The collection to inspect.
  2255. * @param {Function} predicate The function invoked per iteration.
  2256. * @param {Function} eachFunc The function to iterate over `collection`.
  2257. * @returns {*} Returns the found element or its key, else `undefined`.
  2258. */
  2259. function baseFindKey(collection, predicate, eachFunc) {
  2260. var result;
  2261. eachFunc(collection, function(value, key, collection) {
  2262. if (predicate(value, key, collection)) {
  2263. result = key;
  2264. return false;
  2265. }
  2266. });
  2267. return result;
  2268. }
  2269. /**
  2270. * The base implementation of `_.findIndex` and `_.findLastIndex` without
  2271. * support for iteratee shorthands.
  2272. *
  2273. * @private
  2274. * @param {Array} array The array to inspect.
  2275. * @param {Function} predicate The function invoked per iteration.
  2276. * @param {number} fromIndex The index to search from.
  2277. * @param {boolean} [fromRight] Specify iterating from right to left.
  2278. * @returns {number} Returns the index of the matched value, else `-1`.
  2279. */
  2280. function baseFindIndex(array, predicate, fromIndex, fromRight) {
  2281. var length = array.length,
  2282. index = fromIndex + (fromRight ? 1 : -1);
  2283. while ((fromRight ? index-- : ++index < length)) {
  2284. if (predicate(array[index], index, array)) {
  2285. return index;
  2286. }
  2287. }
  2288. return -1;
  2289. }
  2290. /**
  2291. * The base implementation of `_.indexOf` without `fromIndex` bounds checks.
  2292. *
  2293. * @private
  2294. * @param {Array} array The array to inspect.
  2295. * @param {*} value The value to search for.
  2296. * @param {number} fromIndex The index to search from.
  2297. * @returns {number} Returns the index of the matched value, else `-1`.
  2298. */
  2299. function baseIndexOf(array, value, fromIndex) {
  2300. return value === value
  2301. ? strictIndexOf(array, value, fromIndex)
  2302. : baseFindIndex(array, baseIsNaN, fromIndex);
  2303. }
  2304. /**
  2305. * This function is like `baseIndexOf` except that it accepts a comparator.
  2306. *
  2307. * @private
  2308. * @param {Array} array The array to inspect.
  2309. * @param {*} value The value to search for.
  2310. * @param {number} fromIndex The index to search from.
  2311. * @param {Function} comparator The comparator invoked per element.
  2312. * @returns {number} Returns the index of the matched value, else `-1`.
  2313. */
  2314. function baseIndexOfWith(array, value, fromIndex, comparator) {
  2315. var index = fromIndex - 1,
  2316. length = array.length;
  2317. while (++index < length) {
  2318. if (comparator(array[index], value)) {
  2319. return index;
  2320. }
  2321. }
  2322. return -1;
  2323. }
  2324. /**
  2325. * The base implementation of `_.isNaN` without support for number objects.
  2326. *
  2327. * @private
  2328. * @param {*} value The value to check.
  2329. * @returns {boolean} Returns `true` if `value` is `NaN`, else `false`.
  2330. */
  2331. function baseIsNaN(value) {
  2332. return value !== value;
  2333. }
  2334. /**
  2335. * The base implementation of `_.mean` and `_.meanBy` without support for
  2336. * iteratee shorthands.
  2337. *
  2338. * @private
  2339. * @param {Array} array The array to iterate over.
  2340. * @param {Function} iteratee The function invoked per iteration.
  2341. * @returns {number} Returns the mean.
  2342. */
  2343. function baseMean(array, iteratee) {
  2344. var length = array == null ? 0 : array.length;
  2345. return length ? (baseSum(array, iteratee) / length) : NAN;
  2346. }
  2347. /**
  2348. * The base implementation of `_.property` without support for deep paths.
  2349. *
  2350. * @private
  2351. * @param {string} key The key of the property to get.
  2352. * @returns {Function} Returns the new accessor function.
  2353. */
  2354. function baseProperty(key) {
  2355. return function(object) {
  2356. return object == null ? undefined : object[key];
  2357. };
  2358. }
  2359. /**
  2360. * The base implementation of `_.propertyOf` without support for deep paths.
  2361. *
  2362. * @private
  2363. * @param {Object} object The object to query.
  2364. * @returns {Function} Returns the new accessor function.
  2365. */
  2366. function basePropertyOf(object) {
  2367. return function(key) {
  2368. return object == null ? undefined : object[key];
  2369. };
  2370. }
  2371. /**
  2372. * The base implementation of `_.reduce` and `_.reduceRight`, without support
  2373. * for iteratee shorthands, which iterates over `collection` using `eachFunc`.
  2374. *
  2375. * @private
  2376. * @param {Array|Object} collection The collection to iterate over.
  2377. * @param {Function} iteratee The function invoked per iteration.
  2378. * @param {*} accumulator The initial value.
  2379. * @param {boolean} initAccum Specify using the first or last element of
  2380. * `collection` as the initial value.
  2381. * @param {Function} eachFunc The function to iterate over `collection`.
  2382. * @returns {*} Returns the accumulated value.
  2383. */
  2384. function baseReduce(collection, iteratee, accumulator, initAccum, eachFunc) {
  2385. eachFunc(collection, function(value, index, collection) {
  2386. accumulator = initAccum
  2387. ? (initAccum = false, value)
  2388. : iteratee(accumulator, value, index, collection);
  2389. });
  2390. return accumulator;
  2391. }
  2392. /**
  2393. * The base implementation of `_.sortBy` which uses `comparer` to define the
  2394. * sort order of `array` and replaces criteria objects with their corresponding
  2395. * values.
  2396. *
  2397. * @private
  2398. * @param {Array} array The array to sort.
  2399. * @param {Function} comparer The function to define sort order.
  2400. * @returns {Array} Returns `array`.
  2401. */
  2402. function baseSortBy(array, comparer) {
  2403. var length = array.length;
  2404. array.sort(comparer);
  2405. while (length--) {
  2406. array[length] = array[length].value;
  2407. }
  2408. return array;
  2409. }
  2410. /**
  2411. * The base implementation of `_.sum` and `_.sumBy` without support for
  2412. * iteratee shorthands.
  2413. *
  2414. * @private
  2415. * @param {Array} array The array to iterate over.
  2416. * @param {Function} iteratee The function invoked per iteration.
  2417. * @returns {number} Returns the sum.
  2418. */
  2419. function baseSum(array, iteratee) {
  2420. var result,
  2421. index = -1,
  2422. length = array.length;
  2423. while (++index < length) {
  2424. var current = iteratee(array[index]);
  2425. if (current !== undefined) {
  2426. result = result === undefined ? current : (result + current);
  2427. }
  2428. }
  2429. return result;
  2430. }
  2431. /**
  2432. * The base implementation of `_.times` without support for iteratee shorthands
  2433. * or max array length checks.
  2434. *
  2435. * @private
  2436. * @param {number} n The number of times to invoke `iteratee`.
  2437. * @param {Function} iteratee The function invoked per iteration.
  2438. * @returns {Array} Returns the array of results.
  2439. */
  2440. function baseTimes(n, iteratee) {
  2441. var index = -1,
  2442. result = Array(n);
  2443. while (++index < n) {
  2444. result[index] = iteratee(index);
  2445. }
  2446. return result;
  2447. }
  2448. /**
  2449. * The base implementation of `_.toPairs` and `_.toPairsIn` which creates an array
  2450. * of key-value pairs for `object` corresponding to the property names of `props`.
  2451. *
  2452. * @private
  2453. * @param {Object} object The object to query.
  2454. * @param {Array} props The property names to get values for.
  2455. * @returns {Object} Returns the key-value pairs.
  2456. */
  2457. function baseToPairs(object, props) {
  2458. return arrayMap(props, function(key) {
  2459. return [key, object[key]];
  2460. });
  2461. }
  2462. /**
  2463. * The base implementation of `_.unary` without support for storing metadata.
  2464. *
  2465. * @private
  2466. * @param {Function} func The function to cap arguments for.
  2467. * @returns {Function} Returns the new capped function.
  2468. */
  2469. function baseUnary(func) {
  2470. return function(value) {
  2471. return func(value);
  2472. };
  2473. }
  2474. /**
  2475. * The base implementation of `_.values` and `_.valuesIn` which creates an
  2476. * array of `object` property values corresponding to the property names
  2477. * of `props`.
  2478. *
  2479. * @private
  2480. * @param {Object} object The object to query.
  2481. * @param {Array} props The property names to get values for.
  2482. * @returns {Object} Returns the array of property values.
  2483. */
  2484. function baseValues(object, props) {
  2485. return arrayMap(props, function(key) {
  2486. return object[key];
  2487. });
  2488. }
  2489. /**
  2490. * Checks if a `cache` value for `key` exists.
  2491. *
  2492. * @private
  2493. * @param {Object} cache The cache to query.
  2494. * @param {string} key The key of the entry to check.
  2495. * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
  2496. */
  2497. function cacheHas(cache, key) {
  2498. return cache.has(key);
  2499. }
  2500. /**
  2501. * Used by `_.trim` and `_.trimStart` to get the index of the first string symbol
  2502. * that is not found in the character symbols.
  2503. *
  2504. * @private
  2505. * @param {Array} strSymbols The string symbols to inspect.
  2506. * @param {Array} chrSymbols The character symbols to find.
  2507. * @returns {number} Returns the index of the first unmatched string symbol.
  2508. */
  2509. function charsStartIndex(strSymbols, chrSymbols) {
  2510. var index = -1,
  2511. length = strSymbols.length;
  2512. while (++index < length && baseIndexOf(chrSymbols, strSymbols[index], 0) > -1) {}
  2513. return index;
  2514. }
  2515. /**
  2516. * Used by `_.trim` and `_.trimEnd` to get the index of the last string symbol
  2517. * that is not found in the character symbols.
  2518. *
  2519. * @private
  2520. * @param {Array} strSymbols The string symbols to inspect.
  2521. * @param {Array} chrSymbols The character symbols to find.
  2522. * @returns {number} Returns the index of the last unmatched string symbol.
  2523. */
  2524. function charsEndIndex(strSymbols, chrSymbols) {
  2525. var index = strSymbols.length;
  2526. while (index-- && baseIndexOf(chrSymbols, strSymbols[index], 0) > -1) {}
  2527. return index;
  2528. }
  2529. /**
  2530. * Gets the number of `placeholder` occurrences in `array`.
  2531. *
  2532. * @private
  2533. * @param {Array} array The array to inspect.
  2534. * @param {*} placeholder The placeholder to search for.
  2535. * @returns {number} Returns the placeholder count.
  2536. */
  2537. function countHolders(array, placeholder) {
  2538. var length = array.length,
  2539. result = 0;
  2540. while (length--) {
  2541. if (array[length] === placeholder) {
  2542. ++result;
  2543. }
  2544. }
  2545. return result;
  2546. }
  2547. /**
  2548. * Used by `_.deburr` to convert Latin-1 Supplement and Latin Extended-A
  2549. * letters to basic Latin letters.
  2550. *
  2551. * @private
  2552. * @param {string} letter The matched letter to deburr.
  2553. * @returns {string} Returns the deburred letter.
  2554. */
  2555. var deburrLetter = basePropertyOf(deburredLetters);
  2556. /**
  2557. * Used by `_.escape` to convert characters to HTML entities.
  2558. *
  2559. * @private
  2560. * @param {string} chr The matched character to escape.
  2561. * @returns {string} Returns the escaped character.
  2562. */
  2563. var escapeHtmlChar = basePropertyOf(htmlEscapes);
  2564. /**
  2565. * Used by `_.template` to escape characters for inclusion in compiled string literals.
  2566. *
  2567. * @private
  2568. * @param {string} chr The matched character to escape.
  2569. * @returns {string} Returns the escaped character.
  2570. */
  2571. function escapeStringChar(chr) {
  2572. return '\\' + stringEscapes[chr];
  2573. }
  2574. /**
  2575. * Gets the value at `key` of `object`.
  2576. *
  2577. * @private
  2578. * @param {Object} [object] The object to query.
  2579. * @param {string} key The key of the property to get.
  2580. * @returns {*} Returns the property value.
  2581. */
  2582. function getValue(object, key) {
  2583. return object == null ? undefined : object[key];
  2584. }
  2585. /**
  2586. * Checks if `string` contains Unicode symbols.
  2587. *
  2588. * @private
  2589. * @param {string} string The string to inspect.
  2590. * @returns {boolean} Returns `true` if a symbol is found, else `false`.
  2591. */
  2592. function hasUnicode(string) {
  2593. return reHasUnicode.test(string);
  2594. }
  2595. /**
  2596. * Checks if `string` contains a word composed of Unicode symbols.
  2597. *
  2598. * @private
  2599. * @param {string} string The string to inspect.
  2600. * @returns {boolean} Returns `true` if a word is found, else `false`.
  2601. */
  2602. function hasUnicodeWord(string) {
  2603. return reHasUnicodeWord.test(string);
  2604. }
  2605. /**
  2606. * Converts `iterator` to an array.
  2607. *
  2608. * @private
  2609. * @param {Object} iterator The iterator to convert.
  2610. * @returns {Array} Returns the converted array.
  2611. */
  2612. function iteratorToArray(iterator) {
  2613. var data,
  2614. result = [];
  2615. while (!(data = iterator.next()).done) {
  2616. result.push(data.value);
  2617. }
  2618. return result;
  2619. }
  2620. /**
  2621. * Converts `map` to its key-value pairs.
  2622. *
  2623. * @private
  2624. * @param {Object} map The map to convert.
  2625. * @returns {Array} Returns the key-value pairs.
  2626. */
  2627. function mapToArray(map) {
  2628. var index = -1,
  2629. result = Array(map.size);
  2630. map.forEach(function(value, key) {
  2631. result[++index] = [key, value];
  2632. });
  2633. return result;
  2634. }
  2635. /**
  2636. * Creates a unary function that invokes `func` with its argument transformed.
  2637. *
  2638. * @private
  2639. * @param {Function} func The function to wrap.
  2640. * @param {Function} transform The argument transform.
  2641. * @returns {Function} Returns the new function.
  2642. */
  2643. function overArg(func, transform) {
  2644. return function(arg) {
  2645. return func(transform(arg));
  2646. };
  2647. }
  2648. /**
  2649. * Replaces all `placeholder` elements in `array` with an internal placeholder
  2650. * and returns an array of their indexes.
  2651. *
  2652. * @private
  2653. * @param {Array} array The array to modify.
  2654. * @param {*} placeholder The placeholder to replace.
  2655. * @returns {Array} Returns the new array of placeholder indexes.
  2656. */
  2657. function replaceHolders(array, placeholder) {
  2658. var index = -1,
  2659. length = array.length,
  2660. resIndex = 0,
  2661. result = [];
  2662. while (++index < length) {
  2663. var value = array[index];
  2664. if (value === placeholder || value === PLACEHOLDER) {
  2665. array[index] = PLACEHOLDER;
  2666. result[resIndex++] = index;
  2667. }
  2668. }
  2669. return result;
  2670. }
  2671. /**
  2672. * Converts `set` to an array of its values.
  2673. *
  2674. * @private
  2675. * @param {Object} set The set to convert.
  2676. * @returns {Array} Returns the values.
  2677. */
  2678. function setToArray(set) {
  2679. var index = -1,
  2680. result = Array(set.size);
  2681. set.forEach(function(value) {
  2682. result[++index] = value;
  2683. });
  2684. return result;
  2685. }
  2686. /**
  2687. * Converts `set` to its value-value pairs.
  2688. *
  2689. * @private
  2690. * @param {Object} set The set to convert.
  2691. * @returns {Array} Returns the value-value pairs.
  2692. */
  2693. function setToPairs(set) {
  2694. var index = -1,
  2695. result = Array(set.size);
  2696. set.forEach(function(value) {
  2697. result[++index] = [value, value];
  2698. });
  2699. return result;
  2700. }
  2701. /**
  2702. * A specialized version of `_.indexOf` which performs strict equality
  2703. * comparisons of values, i.e. `===`.
  2704. *
  2705. * @private
  2706. * @param {Array} array The array to inspect.
  2707. * @param {*} value The value to search for.
  2708. * @param {number} fromIndex The index to search from.
  2709. * @returns {number} Returns the index of the matched value, else `-1`.
  2710. */
  2711. function strictIndexOf(array, value, fromIndex) {
  2712. var index = fromIndex - 1,
  2713. length = array.length;
  2714. while (++index < length) {
  2715. if (array[index] === value) {
  2716. return index;
  2717. }
  2718. }
  2719. return -1;
  2720. }
  2721. /**
  2722. * A specialized version of `_.lastIndexOf` which performs strict equality
  2723. * comparisons of values, i.e. `===`.
  2724. *
  2725. * @private
  2726. * @param {Array} array The array to inspect.
  2727. * @param {*} value The value to search for.
  2728. * @param {number} fromIndex The index to search from.
  2729. * @returns {number} Returns the index of the matched value, else `-1`.
  2730. */
  2731. function strictLastIndexOf(array, value, fromIndex) {
  2732. var index = fromIndex + 1;
  2733. while (index--) {
  2734. if (array[index] === value) {
  2735. return index;
  2736. }
  2737. }
  2738. return index;
  2739. }
  2740. /**
  2741. * Gets the number of symbols in `string`.
  2742. *
  2743. * @private
  2744. * @param {string} string The string to inspect.
  2745. * @returns {number} Returns the string size.
  2746. */
  2747. function stringSize(string) {
  2748. return hasUnicode(string)
  2749. ? unicodeSize(string)
  2750. : asciiSize(string);
  2751. }
  2752. /**
  2753. * Converts `string` to an array.
  2754. *
  2755. * @private
  2756. * @param {string} string The string to convert.
  2757. * @returns {Array} Returns the converted array.
  2758. */
  2759. function stringToArray(string) {
  2760. return hasUnicode(string)
  2761. ? unicodeToArray(string)
  2762. : asciiToArray(string);
  2763. }
  2764. /**
  2765. * Used by `_.unescape` to convert HTML entities to characters.
  2766. *
  2767. * @private
  2768. * @param {string} chr The matched character to unescape.
  2769. * @returns {string} Returns the unescaped character.
  2770. */
  2771. var unescapeHtmlChar = basePropertyOf(htmlUnescapes);
  2772. /**
  2773. * Gets the size of a Unicode `string`.
  2774. *
  2775. * @private
  2776. * @param {string} string The string inspect.
  2777. * @returns {number} Returns the string size.
  2778. */
  2779. function unicodeSize(string) {
  2780. var result = reUnicode.lastIndex = 0;
  2781. while (reUnicode.test(string)) {
  2782. ++result;
  2783. }
  2784. return result;
  2785. }
  2786. /**
  2787. * Converts a Unicode `string` to an array.
  2788. *
  2789. * @private
  2790. * @param {string} string The string to convert.
  2791. * @returns {Array} Returns the converted array.
  2792. */
  2793. function unicodeToArray(string) {
  2794. return string.match(reUnicode) || [];
  2795. }
  2796. /**
  2797. * Splits a Unicode `string` into an array of its words.
  2798. *
  2799. * @private
  2800. * @param {string} The string to inspect.
  2801. * @returns {Array} Returns the words of `string`.
  2802. */
  2803. function unicodeWords(string) {
  2804. return string.match(reUnicodeWord) || [];
  2805. }
  2806. /*--------------------------------------------------------------------------*/
  2807. /**
  2808. * Create a new pristine `lodash` function using the `context` object.
  2809. *
  2810. * @static
  2811. * @memberOf _
  2812. * @since 1.1.0
  2813. * @category Util
  2814. * @param {Object} [context=root] The context object.
  2815. * @returns {Function} Returns a new `lodash` function.
  2816. * @example
  2817. *
  2818. * _.mixin({ 'foo': _.constant('foo') });
  2819. *
  2820. * var lodash = _.runInContext();
  2821. * lodash.mixin({ 'bar': lodash.constant('bar') });
  2822. *
  2823. * _.isFunction(_.foo);
  2824. * // => true
  2825. * _.isFunction(_.bar);
  2826. * // => false
  2827. *
  2828. * lodash.isFunction(lodash.foo);
  2829. * // => false
  2830. * lodash.isFunction(lodash.bar);
  2831. * // => true
  2832. *
  2833. * // Create a suped-up `defer` in Node.js.
  2834. * var defer = _.runInContext({ 'setTimeout': setImmediate }).defer;
  2835. */
  2836. var runInContext = (function runInContext(context) {
  2837. context = context == null ? root : _.defaults(root.Object(), context, _.pick(root, contextProps));
  2838. /** Built-in constructor references. */
  2839. var Array = context.Array,
  2840. Date = context.Date,
  2841. Error = context.Error,
  2842. Function = context.Function,
  2843. Math = context.Math,
  2844. Object = context.Object,
  2845. RegExp = context.RegExp,
  2846. String = context.String,
  2847. TypeError = context.TypeError;
  2848. /** Used for built-in method references. */
  2849. var arrayProto = Array.prototype,
  2850. funcProto = Function.prototype,
  2851. objectProto = Object.prototype;
  2852. /** Used to detect overreaching core-js shims. */
  2853. var coreJsData = context['__core-js_shared__'];
  2854. /** Used to resolve the decompiled source of functions. */
  2855. var funcToString = funcProto.toString;
  2856. /** Used to check objects for own properties. */
  2857. var hasOwnProperty = objectProto.hasOwnProperty;
  2858. /** Used to generate unique IDs. */
  2859. var idCounter = 0;
  2860. /** Used to detect methods masquerading as native. */
  2861. var maskSrcKey = (function() {
  2862. var uid = /[^.]+$/.exec(coreJsData && coreJsData.keys && coreJsData.keys.IE_PROTO || '');
  2863. return uid ? ('Symbol(src)_1.' + uid) : '';
  2864. }());
  2865. /**
  2866. * Used to resolve the
  2867. * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
  2868. * of values.
  2869. */
  2870. var nativeObjectToString = objectProto.toString;
  2871. /** Used to infer the `Object` constructor. */
  2872. var objectCtorString = funcToString.call(Object);
  2873. /** Used to restore the original `_` reference in `_.noConflict`. */
  2874. var oldDash = root._;
  2875. /** Used to detect if a method is native. */
  2876. var reIsNative = RegExp('^' +
  2877. funcToString.call(hasOwnProperty).replace(reRegExpChar, '\\$&')
  2878. .replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, '$1.*?') + '$'
  2879. );
  2880. /** Built-in value references. */
  2881. var Buffer = moduleExports ? context.Buffer : undefined,
  2882. Symbol = context.Symbol,
  2883. Uint8Array = context.Uint8Array,
  2884. allocUnsafe = Buffer ? Buffer.allocUnsafe : undefined,
  2885. getPrototype = overArg(Object.getPrototypeOf, Object),
  2886. objectCreate = Object.create,
  2887. propertyIsEnumerable = objectProto.propertyIsEnumerable,
  2888. splice = arrayProto.splice,
  2889. spreadableSymbol = Symbol ? Symbol.isConcatSpreadable : undefined,
  2890. symIterator = Symbol ? Symbol.iterator : undefined,
  2891. symToStringTag = Symbol ? Symbol.toStringTag : undefined;
  2892. var defineProperty = (function() {
  2893. try {
  2894. var func = getNative(Object, 'defineProperty');
  2895. func({}, '', {});
  2896. return func;
  2897. } catch (e) {}
  2898. }());
  2899. /** Mocked built-ins. */
  2900. var ctxClearTimeout = context.clearTimeout !== root.clearTimeout && context.clearTimeout,
  2901. ctxNow = Date && Date.now !== root.Date.now && Date.now,
  2902. ctxSetTimeout = context.setTimeout !== root.setTimeout && context.setTimeout;
  2903. /* Built-in method references for those with the same name as other `lodash` methods. */
  2904. var nativeCeil = Math.ceil,
  2905. nativeFloor = Math.floor,
  2906. nativeGetSymbols = Object.getOwnPropertySymbols,
  2907. nativeIsBuffer = Buffer ? Buffer.isBuffer : undefined,
  2908. nativeIsFinite = context.isFinite,
  2909. nativeJoin = arrayProto.join,
  2910. nativeKeys = overArg(Object.keys, Object),
  2911. nativeMax = Math.max,
  2912. nativeMin = Math.min,
  2913. nativeNow = Date.now,
  2914. nativeParseInt = context.parseInt,
  2915. nativeRandom = Math.random,
  2916. nativeReverse = arrayProto.reverse;
  2917. /* Built-in method references that are verified to be native. */
  2918. var DataView = getNative(context, 'DataView'),
  2919. Map = getNative(context, 'Map'),
  2920. Promise = getNative(context, 'Promise'),
  2921. Set = getNative(context, 'Set'),
  2922. WeakMap = getNative(context, 'WeakMap'),
  2923. nativeCreate = getNative(Object, 'create');
  2924. /** Used to store function metadata. */
  2925. var metaMap = WeakMap && new WeakMap;
  2926. /** Used to lookup unminified function names. */
  2927. var realNames = {};
  2928. /** Used to detect maps, sets, and weakmaps. */
  2929. var dataViewCtorString = toSource(DataView),
  2930. mapCtorString = toSource(Map),
  2931. promiseCtorString = toSource(Promise),
  2932. setCtorString = toSource(Set),
  2933. weakMapCtorString = toSource(WeakMap);
  2934. /** Used to convert symbols to primitives and strings. */
  2935. var symbolProto = Symbol ? Symbol.prototype : undefined,
  2936. symbolValueOf = symbolProto ? symbolProto.valueOf : undefined,
  2937. symbolToString = symbolProto ? symbolProto.toString : undefined;
  2938. /*------------------------------------------------------------------------*/
  2939. /**
  2940. * Creates a `lodash` object which wraps `value` to enable implicit method
  2941. * chain sequences. Methods that operate on and return arrays, collections,
  2942. * and functions can be chained together. Methods that retrieve a single value
  2943. * or may return a primitive value will automatically end the chain sequence
  2944. * and return the unwrapped value. Otherwise, the value must be unwrapped
  2945. * with `_#value`.
  2946. *
  2947. * Explicit chain sequences, which must be unwrapped with `_#value`, may be
  2948. * enabled using `_.chain`.
  2949. *
  2950. * The execution of chained methods is lazy, that is, it's deferred until
  2951. * `_#value` is implicitly or explicitly called.
  2952. *
  2953. * Lazy evaluation allows several methods to support shortcut fusion.
  2954. * Shortcut fusion is an optimization to merge iteratee calls; this avoids
  2955. * the creation of intermediate arrays and can greatly reduce the number of
  2956. * iteratee executions. Sections of a chain sequence qualify for shortcut
  2957. * fusion if the section is applied to an array and iteratees accept only
  2958. * one argument. The heuristic for whether a section qualifies for shortcut
  2959. * fusion is subject to change.
  2960. *
  2961. * Chaining is supported in custom builds as long as the `_#value` method is
  2962. * directly or indirectly included in the build.
  2963. *
  2964. * In addition to lodash methods, wrappers have `Array` and `String` methods.
  2965. *
  2966. * The wrapper `Array` methods are:
  2967. * `concat`, `join`, `pop`, `push`, `shift`, `sort`, `splice`, and `unshift`
  2968. *
  2969. * The wrapper `String` methods are:
  2970. * `replace` and `split`
  2971. *
  2972. * The wrapper methods that support shortcut fusion are:
  2973. * `at`, `compact`, `drop`, `dropRight`, `dropWhile`, `filter`, `find`,
  2974. * `findLast`, `head`, `initial`, `last`, `map`, `reject`, `reverse`, `slice`,
  2975. * `tail`, `take`, `takeRight`, `takeRightWhile`, `takeWhile`, and `toArray`
  2976. *
  2977. * The chainable wrapper methods are:
  2978. * `after`, `ary`, `assign`, `assignIn`, `assignInWith`, `assignWith`, `at`,
  2979. * `before`, `bind`, `bindAll`, `bindKey`, `castArray`, `chain`, `chunk`,
  2980. * `commit`, `compact`, `concat`, `conforms`, `constant`, `countBy`, `create`,
  2981. * `curry`, `debounce`, `defaults`, `defaultsDeep`, `defer`, `delay`,
  2982. * `difference`, `differenceBy`, `differenceWith`, `drop`, `dropRight`,
  2983. * `dropRightWhile`, `dropWhile`, `extend`, `extendWith`, `fill`, `filter`,
  2984. * `flatMap`, `flatMapDeep`, `flatMapDepth`, `flatten`, `flattenDeep`,
  2985. * `flattenDepth`, `flip`, `flow`, `flowRight`, `fromPairs`, `functions`,
  2986. * `functionsIn`, `groupBy`, `initial`, `intersection`, `intersectionBy`,
  2987. * `intersectionWith`, `invert`, `invertBy`, `invokeMap`, `iteratee`, `keyBy`,
  2988. * `keys`, `keysIn`, `map`, `mapKeys`, `mapValues`, `matches`, `matchesProperty`,
  2989. * `memoize`, `merge`, `mergeWith`, `method`, `methodOf`, `mixin`, `negate`,
  2990. * `nthArg`, `omit`, `omitBy`, `once`, `orderBy`, `over`, `overArgs`,
  2991. * `overEvery`, `overSome`, `partial`, `partialRight`, `partition`, `pick`,
  2992. * `pickBy`, `plant`, `property`, `propertyOf`, `pull`, `pullAll`, `pullAllBy`,
  2993. * `pullAllWith`, `pullAt`, `push`, `range`, `rangeRight`, `rearg`, `reject`,
  2994. * `remove`, `rest`, `reverse`, `sampleSize`, `set`, `setWith`, `shuffle`,
  2995. * `slice`, `sort`, `sortBy`, `splice`, `spread`, `tail`, `take`, `takeRight`,
  2996. * `takeRightWhile`, `takeWhile`, `tap`, `throttle`, `thru`, `toArray`,
  2997. * `toPairs`, `toPairsIn`, `toPath`, `toPlainObject`, `transform`, `unary`,
  2998. * `union`, `unionBy`, `unionWith`, `uniq`, `uniqBy`, `uniqWith`, `unset`,
  2999. * `unshift`, `unzip`, `unzipWith`, `update`, `updateWith`, `values`,
  3000. * `valuesIn`, `without`, `wrap`, `xor`, `xorBy`, `xorWith`, `zip`,
  3001. * `zipObject`, `zipObjectDeep`, and `zipWith`
  3002. *
  3003. * The wrapper methods that are **not** chainable by default are:
  3004. * `add`, `attempt`, `camelCase`, `capitalize`, `ceil`, `clamp`, `clone`,
  3005. * `cloneDeep`, `cloneDeepWith`, `cloneWith`, `conformsTo`, `deburr`,
  3006. * `defaultTo`, `divide`, `each`, `eachRight`, `endsWith`, `eq`, `escape`,
  3007. * `escapeRegExp`, `every`, `find`, `findIndex`, `findKey`, `findLast`,
  3008. * `findLastIndex`, `findLastKey`, `first`, `floor`, `forEach`, `forEachRight`,
  3009. * `forIn`, `forInRight`, `forOwn`, `forOwnRight`, `get`, `gt`, `gte`, `has`,
  3010. * `hasIn`, `head`, `identity`, `includes`, `indexOf`, `inRange`, `invoke`,
  3011. * `isArguments`, `isArray`, `isArrayBuffer`, `isArrayLike`, `isArrayLikeObject`,
  3012. * `isBoolean`, `isBuffer`, `isDate`, `isElement`, `isEmpty`, `isEqual`,
  3013. * `isEqualWith`, `isError`, `isFinite`, `isFunction`, `isInteger`, `isLength`,
  3014. * `isMap`, `isMatch`, `isMatchWith`, `isNaN`, `isNative`, `isNil`, `isNull`,
  3015. * `isNumber`, `isObject`, `isObjectLike`, `isPlainObject`, `isRegExp`,
  3016. * `isSafeInteger`, `isSet`, `isString`, `isUndefined`, `isTypedArray`,
  3017. * `isWeakMap`, `isWeakSet`, `join`, `kebabCase`, `last`, `lastIndexOf`,
  3018. * `lowerCase`, `lowerFirst`, `lt`, `lte`, `max`, `maxBy`, `mean`, `meanBy`,
  3019. * `min`, `minBy`, `multiply`, `noConflict`, `noop`, `now`, `nth`, `pad`,
  3020. * `padEnd`, `padStart`, `parseInt`, `pop`, `random`, `reduce`, `reduceRight`,
  3021. * `repeat`, `result`, `round`, `runInContext`, `sample`, `shift`, `size`,
  3022. * `snakeCase`, `some`, `sortedIndex`, `sortedIndexBy`, `sortedLastIndex`,
  3023. * `sortedLastIndexBy`, `startCase`, `startsWith`, `stubArray`, `stubFalse`,
  3024. * `stubObject`, `stubString`, `stubTrue`, `subtract`, `sum`, `sumBy`,
  3025. * `template`, `times`, `toFinite`, `toInteger`, `toJSON`, `toLength`,
  3026. * `toLower`, `toNumber`, `toSafeInteger`, `toString`, `toUpper`, `trim`,
  3027. * `trimEnd`, `trimStart`, `truncate`, `unescape`, `uniqueId`, `upperCase`,
  3028. * `upperFirst`, `value`, and `words`
  3029. *
  3030. * @name _
  3031. * @constructor
  3032. * @category Seq
  3033. * @param {*} value The value to wrap in a `lodash` instance.
  3034. * @returns {Object} Returns the new `lodash` wrapper instance.
  3035. * @example
  3036. *
  3037. * function square(n) {
  3038. * return n * n;
  3039. * }
  3040. *
  3041. * var wrapped = _([1, 2, 3]);
  3042. *
  3043. * // Returns an unwrapped value.
  3044. * wrapped.reduce(_.add);
  3045. * // => 6
  3046. *
  3047. * // Returns a wrapped value.
  3048. * var squares = wrapped.map(square);
  3049. *
  3050. * _.isArray(squares);
  3051. * // => false
  3052. *
  3053. * _.isArray(squares.value());
  3054. * // => true
  3055. */
  3056. function lodash(value) {
  3057. if (isObjectLike(value) && !isArray(value) && !(value instanceof LazyWrapper)) {
  3058. if (value instanceof LodashWrapper) {
  3059. return value;
  3060. }
  3061. if (hasOwnProperty.call(value, '__wrapped__')) {
  3062. return wrapperClone(value);
  3063. }
  3064. }
  3065. return new LodashWrapper(value);
  3066. }
  3067. /**
  3068. * The base implementation of `_.create` without support for assigning
  3069. * properties to the created object.
  3070. *
  3071. * @private
  3072. * @param {Object} proto The object to inherit from.
  3073. * @returns {Object} Returns the new object.
  3074. */
  3075. var baseCreate = (function() {
  3076. function object() {}
  3077. return function(proto) {
  3078. if (!isObject(proto)) {
  3079. return {};
  3080. }
  3081. if (objectCreate) {
  3082. return objectCreate(proto);
  3083. }
  3084. object.prototype = proto;
  3085. var result = new object;
  3086. object.prototype = undefined;
  3087. return result;
  3088. };
  3089. }());
  3090. /**
  3091. * The function whose prototype chain sequence wrappers inherit from.
  3092. *
  3093. * @private
  3094. */
  3095. function baseLodash() {
  3096. // No operation performed.
  3097. }
  3098. /**
  3099. * The base constructor for creating `lodash` wrapper objects.
  3100. *
  3101. * @private
  3102. * @param {*} value The value to wrap.
  3103. * @param {boolean} [chainAll] Enable explicit method chain sequences.
  3104. */
  3105. function LodashWrapper(value, chainAll) {
  3106. this.__wrapped__ = value;
  3107. this.__actions__ = [];
  3108. this.__chain__ = !!chainAll;
  3109. this.__index__ = 0;
  3110. this.__values__ = undefined;
  3111. }
  3112. /**
  3113. * By default, the template delimiters used by lodash are like those in
  3114. * embedded Ruby (ERB) as well as ES2015 template strings. Change the
  3115. * following template settings to use alternative delimiters.
  3116. *
  3117. * @static
  3118. * @memberOf _
  3119. * @type {Object}
  3120. */
  3121. lodash.templateSettings = {
  3122. /**
  3123. * Used to detect `data` property values to be HTML-escaped.
  3124. *
  3125. * @memberOf _.templateSettings
  3126. * @type {RegExp}
  3127. */
  3128. 'escape': reEscape,
  3129. /**
  3130. * Used to detect code to be evaluated.
  3131. *
  3132. * @memberOf _.templateSettings
  3133. * @type {RegExp}
  3134. */
  3135. 'evaluate': reEvaluate,
  3136. /**
  3137. * Used to detect `data` property values to inject.
  3138. *
  3139. * @memberOf _.templateSettings
  3140. * @type {RegExp}
  3141. */
  3142. 'interpolate': reInterpolate,
  3143. /**
  3144. * Used to reference the data object in the template text.
  3145. *
  3146. * @memberOf _.templateSettings
  3147. * @type {string}
  3148. */
  3149. 'variable': '',
  3150. /**
  3151. * Used to import variables into the compiled template.
  3152. *
  3153. * @memberOf _.templateSettings
  3154. * @type {Object}
  3155. */
  3156. 'imports': {
  3157. /**
  3158. * A reference to the `lodash` function.
  3159. *
  3160. * @memberOf _.templateSettings.imports
  3161. * @type {Function}
  3162. */
  3163. '_': lodash
  3164. }
  3165. };
  3166. // Ensure wrappers are instances of `baseLodash`.
  3167. lodash.prototype = baseLodash.prototype;
  3168. lodash.prototype.constructor = lodash;
  3169. LodashWrapper.prototype = baseCreate(baseLodash.prototype);
  3170. LodashWrapper.prototype.constructor = LodashWrapper;
  3171. /*------------------------------------------------------------------------*/
  3172. /**
  3173. * Creates a lazy wrapper object which wraps `value` to enable lazy evaluation.
  3174. *
  3175. * @private
  3176. * @constructor
  3177. * @param {*} value The value to wrap.
  3178. */
  3179. function LazyWrapper(value) {
  3180. this.__wrapped__ = value;
  3181. this.__actions__ = [];
  3182. this.__dir__ = 1;
  3183. this.__filtered__ = false;
  3184. this.__iteratees__ = [];
  3185. this.__takeCount__ = MAX_ARRAY_LENGTH;
  3186. this.__views__ = [];
  3187. }
  3188. /**
  3189. * Creates a clone of the lazy wrapper object.
  3190. *
  3191. * @private
  3192. * @name clone
  3193. * @memberOf LazyWrapper
  3194. * @returns {Object} Returns the cloned `LazyWrapper` object.
  3195. */
  3196. function lazyClone() {
  3197. var result = new LazyWrapper(this.__wrapped__);
  3198. result.__actions__ = copyArray(this.__actions__);
  3199. result.__dir__ = this.__dir__;
  3200. result.__filtered__ = this.__filtered__;
  3201. result.__iteratees__ = copyArray(this.__iteratees__);
  3202. result.__takeCount__ = this.__takeCount__;
  3203. result.__views__ = copyArray(this.__views__);
  3204. return result;
  3205. }
  3206. /**
  3207. * Reverses the direction of lazy iteration.
  3208. *
  3209. * @private
  3210. * @name reverse
  3211. * @memberOf LazyWrapper
  3212. * @returns {Object} Returns the new reversed `LazyWrapper` object.
  3213. */
  3214. function lazyReverse() {
  3215. if (this.__filtered__) {
  3216. var result = new LazyWrapper(this);
  3217. result.__dir__ = -1;
  3218. result.__filtered__ = true;
  3219. } else {
  3220. result = this.clone();
  3221. result.__dir__ *= -1;
  3222. }
  3223. return result;
  3224. }
  3225. /**
  3226. * Extracts the unwrapped value from its lazy wrapper.
  3227. *
  3228. * @private
  3229. * @name value
  3230. * @memberOf LazyWrapper
  3231. * @returns {*} Returns the unwrapped value.
  3232. */
  3233. function lazyValue() {
  3234. var array = this.__wrapped__.value(),
  3235. dir = this.__dir__,
  3236. isArr = isArray(array),
  3237. isRight = dir < 0,
  3238. arrLength = isArr ? array.length : 0,
  3239. view = getView(0, arrLength, this.__views__),
  3240. start = view.start,
  3241. end = view.end,
  3242. length = end - start,
  3243. index = isRight ? end : (start - 1),
  3244. iteratees = this.__iteratees__,
  3245. iterLength = iteratees.length,
  3246. resIndex = 0,
  3247. takeCount = nativeMin(length, this.__takeCount__);
  3248. if (!isArr || (!isRight && arrLength == length && takeCount == length)) {
  3249. return baseWrapperValue(array, this.__actions__);
  3250. }
  3251. var result = [];
  3252. outer:
  3253. while (length-- && resIndex < takeCount) {
  3254. index += dir;
  3255. var iterIndex = -1,
  3256. value = array[index];
  3257. while (++iterIndex < iterLength) {
  3258. var data = iteratees[iterIndex],
  3259. iteratee = data.iteratee,
  3260. type = data.type,
  3261. computed = iteratee(value);
  3262. if (type == LAZY_MAP_FLAG) {
  3263. value = computed;
  3264. } else if (!computed) {
  3265. if (type == LAZY_FILTER_FLAG) {
  3266. continue outer;
  3267. } else {
  3268. break outer;
  3269. }
  3270. }
  3271. }
  3272. result[resIndex++] = value;
  3273. }
  3274. return result;
  3275. }
  3276. // Ensure `LazyWrapper` is an instance of `baseLodash`.
  3277. LazyWrapper.prototype = baseCreate(baseLodash.prototype);
  3278. LazyWrapper.prototype.constructor = LazyWrapper;
  3279. /*------------------------------------------------------------------------*/
  3280. /**
  3281. * Creates a hash object.
  3282. *
  3283. * @private
  3284. * @constructor
  3285. * @param {Array} [entries] The key-value pairs to cache.
  3286. */
  3287. function Hash(entries) {
  3288. var index = -1,
  3289. length = entries == null ? 0 : entries.length;
  3290. this.clear();
  3291. while (++index < length) {
  3292. var entry = entries[index];
  3293. this.set(entry[0], entry[1]);
  3294. }
  3295. }
  3296. /**
  3297. * Removes all key-value entries from the hash.
  3298. *
  3299. * @private
  3300. * @name clear
  3301. * @memberOf Hash
  3302. */
  3303. function hashClear() {
  3304. this.__data__ = nativeCreate ? nativeCreate(null) : {};
  3305. this.size = 0;
  3306. }
  3307. /**
  3308. * Removes `key` and its value from the hash.
  3309. *
  3310. * @private
  3311. * @name delete
  3312. * @memberOf Hash
  3313. * @param {Object} hash The hash to modify.
  3314. * @param {string} key The key of the value to remove.
  3315. * @returns {boolean} Returns `true` if the entry was removed, else `false`.
  3316. */
  3317. function hashDelete(key) {
  3318. var result = this.has(key) && delete this.__data__[key];
  3319. this.size -= result ? 1 : 0;
  3320. return result;
  3321. }
  3322. /**
  3323. * Gets the hash value for `key`.
  3324. *
  3325. * @private
  3326. * @name get
  3327. * @memberOf Hash
  3328. * @param {string} key The key of the value to get.
  3329. * @returns {*} Returns the entry value.
  3330. */
  3331. function hashGet(key) {
  3332. var data = this.__data__;
  3333. if (nativeCreate) {
  3334. var result = data[key];
  3335. return result === HASH_UNDEFINED ? undefined : result;
  3336. }
  3337. return hasOwnProperty.call(data, key) ? data[key] : undefined;
  3338. }
  3339. /**
  3340. * Checks if a hash value for `key` exists.
  3341. *
  3342. * @private
  3343. * @name has
  3344. * @memberOf Hash
  3345. * @param {string} key The key of the entry to check.
  3346. * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
  3347. */
  3348. function hashHas(key) {
  3349. var data = this.__data__;
  3350. return nativeCreate ? (data[key] !== undefined) : hasOwnProperty.call(data, key);
  3351. }
  3352. /**
  3353. * Sets the hash `key` to `value`.
  3354. *
  3355. * @private
  3356. * @name set
  3357. * @memberOf Hash
  3358. * @param {string} key The key of the value to set.
  3359. * @param {*} value The value to set.
  3360. * @returns {Object} Returns the hash instance.
  3361. */
  3362. function hashSet(key, value) {
  3363. var data = this.__data__;
  3364. this.size += this.has(key) ? 0 : 1;
  3365. data[key] = (nativeCreate && value === undefined) ? HASH_UNDEFINED : value;
  3366. return this;
  3367. }
  3368. // Add methods to `Hash`.
  3369. Hash.prototype.clear = hashClear;
  3370. Hash.prototype['delete'] = hashDelete;
  3371. Hash.prototype.get = hashGet;
  3372. Hash.prototype.has = hashHas;
  3373. Hash.prototype.set = hashSet;
  3374. /*------------------------------------------------------------------------*/
  3375. /**
  3376. * Creates an list cache object.
  3377. *
  3378. * @private
  3379. * @constructor
  3380. * @param {Array} [entries] The key-value pairs to cache.
  3381. */
  3382. function ListCache(entries) {
  3383. var index = -1,
  3384. length = entries == null ? 0 : entries.length;
  3385. this.clear();
  3386. while (++index < length) {
  3387. var entry = entries[index];
  3388. this.set(entry[0], entry[1]);
  3389. }
  3390. }
  3391. /**
  3392. * Removes all key-value entries from the list cache.
  3393. *
  3394. * @private
  3395. * @name clear
  3396. * @memberOf ListCache
  3397. */
  3398. function listCacheClear() {
  3399. this.__data__ = [];
  3400. this.size = 0;
  3401. }
  3402. /**
  3403. * Removes `key` and its value from the list cache.
  3404. *
  3405. * @private
  3406. * @name delete
  3407. * @memberOf ListCache
  3408. * @param {string} key The key of the value to remove.
  3409. * @returns {boolean} Returns `true` if the entry was removed, else `false`.
  3410. */
  3411. function listCacheDelete(key) {
  3412. var data = this.__data__,
  3413. index = assocIndexOf(data, key);
  3414. if (index < 0) {
  3415. return false;
  3416. }
  3417. var lastIndex = data.length - 1;
  3418. if (index == lastIndex) {
  3419. data.pop();
  3420. } else {
  3421. splice.call(data, index, 1);
  3422. }
  3423. --this.size;
  3424. return true;
  3425. }
  3426. /**
  3427. * Gets the list cache value for `key`.
  3428. *
  3429. * @private
  3430. * @name get
  3431. * @memberOf ListCache
  3432. * @param {string} key The key of the value to get.
  3433. * @returns {*} Returns the entry value.
  3434. */
  3435. function listCacheGet(key) {
  3436. var data = this.__data__,
  3437. index = assocIndexOf(data, key);
  3438. return index < 0 ? undefined : data[index][1];
  3439. }
  3440. /**
  3441. * Checks if a list cache value for `key` exists.
  3442. *
  3443. * @private
  3444. * @name has
  3445. * @memberOf ListCache
  3446. * @param {string} key The key of the entry to check.
  3447. * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
  3448. */
  3449. function listCacheHas(key) {
  3450. return assocIndexOf(this.__data__, key) > -1;
  3451. }
  3452. /**
  3453. * Sets the list cache `key` to `value`.
  3454. *
  3455. * @private
  3456. * @name set
  3457. * @memberOf ListCache
  3458. * @param {string} key The key of the value to set.
  3459. * @param {*} value The value to set.
  3460. * @returns {Object} Returns the list cache instance.
  3461. */
  3462. function listCacheSet(key, value) {
  3463. var data = this.__data__,
  3464. index = assocIndexOf(data, key);
  3465. if (index < 0) {
  3466. ++this.size;
  3467. data.push([key, value]);
  3468. } else {
  3469. data[index][1] = value;
  3470. }
  3471. return this;
  3472. }
  3473. // Add methods to `ListCache`.
  3474. ListCache.prototype.clear = listCacheClear;
  3475. ListCache.prototype['delete'] = listCacheDelete;
  3476. ListCache.prototype.get = listCacheGet;
  3477. ListCache.prototype.has = listCacheHas;
  3478. ListCache.prototype.set = listCacheSet;
  3479. /*------------------------------------------------------------------------*/
  3480. /**
  3481. * Creates a map cache object to store key-value pairs.
  3482. *
  3483. * @private
  3484. * @constructor
  3485. * @param {Array} [entries] The key-value pairs to cache.
  3486. */
  3487. function MapCache(entries) {
  3488. var index = -1,
  3489. length = entries == null ? 0 : entries.length;
  3490. this.clear();
  3491. while (++index < length) {
  3492. var entry = entries[index];
  3493. this.set(entry[0], entry[1]);
  3494. }
  3495. }
  3496. /**
  3497. * Removes all key-value entries from the map.
  3498. *
  3499. * @private
  3500. * @name clear
  3501. * @memberOf MapCache
  3502. */
  3503. function mapCacheClear() {
  3504. this.size = 0;
  3505. this.__data__ = {
  3506. 'hash': new Hash,
  3507. 'map': new (Map || ListCache),
  3508. 'string': new Hash
  3509. };
  3510. }
  3511. /**
  3512. * Removes `key` and its value from the map.
  3513. *
  3514. * @private
  3515. * @name delete
  3516. * @memberOf MapCache
  3517. * @param {string} key The key of the value to remove.
  3518. * @returns {boolean} Returns `true` if the entry was removed, else `false`.
  3519. */
  3520. function mapCacheDelete(key) {
  3521. var result = getMapData(this, key)['delete'](key);
  3522. this.size -= result ? 1 : 0;
  3523. return result;
  3524. }
  3525. /**
  3526. * Gets the map value for `key`.
  3527. *
  3528. * @private
  3529. * @name get
  3530. * @memberOf MapCache
  3531. * @param {string} key The key of the value to get.
  3532. * @returns {*} Returns the entry value.
  3533. */
  3534. function mapCacheGet(key) {
  3535. return getMapData(this, key).get(key);
  3536. }
  3537. /**
  3538. * Checks if a map value for `key` exists.
  3539. *
  3540. * @private
  3541. * @name has
  3542. * @memberOf MapCache
  3543. * @param {string} key The key of the entry to check.
  3544. * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
  3545. */
  3546. function mapCacheHas(key) {
  3547. return getMapData(this, key).has(key);
  3548. }
  3549. /**
  3550. * Sets the map `key` to `value`.
  3551. *
  3552. * @private
  3553. * @name set
  3554. * @memberOf MapCache
  3555. * @param {string} key The key of the value to set.
  3556. * @param {*} value The value to set.
  3557. * @returns {Object} Returns the map cache instance.
  3558. */
  3559. function mapCacheSet(key, value) {
  3560. var data = getMapData(this, key),
  3561. size = data.size;
  3562. data.set(key, value);
  3563. this.size += data.size == size ? 0 : 1;
  3564. return this;
  3565. }
  3566. // Add methods to `MapCache`.
  3567. MapCache.prototype.clear = mapCacheClear;
  3568. MapCache.prototype['delete'] = mapCacheDelete;
  3569. MapCache.prototype.get = mapCacheGet;
  3570. MapCache.prototype.has = mapCacheHas;
  3571. MapCache.prototype.set = mapCacheSet;
  3572. /*------------------------------------------------------------------------*/
  3573. /**
  3574. *
  3575. * Creates an array cache object to store unique values.
  3576. *
  3577. * @private
  3578. * @constructor
  3579. * @param {Array} [values] The values to cache.
  3580. */
  3581. function SetCache(values) {
  3582. var index = -1,
  3583. length = values == null ? 0 : values.length;
  3584. this.__data__ = new MapCache;
  3585. while (++index < length) {
  3586. this.add(values[index]);
  3587. }
  3588. }
  3589. /**
  3590. * Adds `value` to the array cache.
  3591. *
  3592. * @private
  3593. * @name add
  3594. * @memberOf SetCache
  3595. * @alias push
  3596. * @param {*} value The value to cache.
  3597. * @returns {Object} Returns the cache instance.
  3598. */
  3599. function setCacheAdd(value) {
  3600. this.__data__.set(value, HASH_UNDEFINED);
  3601. return this;
  3602. }
  3603. /**
  3604. * Checks if `value` is in the array cache.
  3605. *
  3606. * @private
  3607. * @name has
  3608. * @memberOf SetCache
  3609. * @param {*} value The value to search for.
  3610. * @returns {number} Returns `true` if `value` is found, else `false`.
  3611. */
  3612. function setCacheHas(value) {
  3613. return this.__data__.has(value);
  3614. }
  3615. // Add methods to `SetCache`.
  3616. SetCache.prototype.add = SetCache.prototype.push = setCacheAdd;
  3617. SetCache.prototype.has = setCacheHas;
  3618. /*------------------------------------------------------------------------*/
  3619. /**
  3620. * Creates a stack cache object to store key-value pairs.
  3621. *
  3622. * @private
  3623. * @constructor
  3624. * @param {Array} [entries] The key-value pairs to cache.
  3625. */
  3626. function Stack(entries) {
  3627. var data = this.__data__ = new ListCache(entries);
  3628. this.size = data.size;
  3629. }
  3630. /**
  3631. * Removes all key-value entries from the stack.
  3632. *
  3633. * @private
  3634. * @name clear
  3635. * @memberOf Stack
  3636. */
  3637. function stackClear() {
  3638. this.__data__ = new ListCache;
  3639. this.size = 0;
  3640. }
  3641. /**
  3642. * Removes `key` and its value from the stack.
  3643. *
  3644. * @private
  3645. * @name delete
  3646. * @memberOf Stack
  3647. * @param {string} key The key of the value to remove.
  3648. * @returns {boolean} Returns `true` if the entry was removed, else `false`.
  3649. */
  3650. function stackDelete(key) {
  3651. var data = this.__data__,
  3652. result = data['delete'](key);
  3653. this.size = data.size;
  3654. return result;
  3655. }
  3656. /**
  3657. * Gets the stack value for `key`.
  3658. *
  3659. * @private
  3660. * @name get
  3661. * @memberOf Stack
  3662. * @param {string} key The key of the value to get.
  3663. * @returns {*} Returns the entry value.
  3664. */
  3665. function stackGet(key) {
  3666. return this.__data__.get(key);
  3667. }
  3668. /**
  3669. * Checks if a stack value for `key` exists.
  3670. *
  3671. * @private
  3672. * @name has
  3673. * @memberOf Stack
  3674. * @param {string} key The key of the entry to check.
  3675. * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
  3676. */
  3677. function stackHas(key) {
  3678. return this.__data__.has(key);
  3679. }
  3680. /**
  3681. * Sets the stack `key` to `value`.
  3682. *
  3683. * @private
  3684. * @name set
  3685. * @memberOf Stack
  3686. * @param {string} key The key of the value to set.
  3687. * @param {*} value The value to set.
  3688. * @returns {Object} Returns the stack cache instance.
  3689. */
  3690. function stackSet(key, value) {
  3691. var data = this.__data__;
  3692. if (data instanceof ListCache) {
  3693. var pairs = data.__data__;
  3694. if (!Map || (pairs.length < LARGE_ARRAY_SIZE - 1)) {
  3695. pairs.push([key, value]);
  3696. this.size = ++data.size;
  3697. return this;
  3698. }
  3699. data = this.__data__ = new MapCache(pairs);
  3700. }
  3701. data.set(key, value);
  3702. this.size = data.size;
  3703. return this;
  3704. }
  3705. // Add methods to `Stack`.
  3706. Stack.prototype.clear = stackClear;
  3707. Stack.prototype['delete'] = stackDelete;
  3708. Stack.prototype.get = stackGet;
  3709. Stack.prototype.has = stackHas;
  3710. Stack.prototype.set = stackSet;
  3711. /*------------------------------------------------------------------------*/
  3712. /**
  3713. * Creates an array of the enumerable property names of the array-like `value`.
  3714. *
  3715. * @private
  3716. * @param {*} value The value to query.
  3717. * @param {boolean} inherited Specify returning inherited property names.
  3718. * @returns {Array} Returns the array of property names.
  3719. */
  3720. function arrayLikeKeys(value, inherited) {
  3721. var isArr = isArray(value),
  3722. isArg = !isArr && isArguments(value),
  3723. isBuff = !isArr && !isArg && isBuffer(value),
  3724. isType = !isArr && !isArg && !isBuff && isTypedArray(value),
  3725. skipIndexes = isArr || isArg || isBuff || isType,
  3726. result = skipIndexes ? baseTimes(value.length, String) : [],
  3727. length = result.length;
  3728. for (var key in value) {
  3729. if ((inherited || hasOwnProperty.call(value, key)) &&
  3730. !(skipIndexes && (
  3731. // Safari 9 has enumerable `arguments.length` in strict mode.
  3732. key == 'length' ||
  3733. // Node.js 0.10 has enumerable non-index properties on buffers.
  3734. (isBuff && (key == 'offset' || key == 'parent')) ||
  3735. // PhantomJS 2 has enumerable non-index properties on typed arrays.
  3736. (isType && (key == 'buffer' || key == 'byteLength' || key == 'byteOffset')) ||
  3737. // Skip index properties.
  3738. isIndex(key, length)
  3739. ))) {
  3740. result.push(key);
  3741. }
  3742. }
  3743. return result;
  3744. }
  3745. /**
  3746. * A specialized version of `_.sample` for arrays.
  3747. *
  3748. * @private
  3749. * @param {Array} array The array to sample.
  3750. * @returns {*} Returns the random element.
  3751. */
  3752. function arraySample(array) {
  3753. var length = array.length;
  3754. return length ? array[baseRandom(0, length - 1)] : undefined;
  3755. }
  3756. /**
  3757. * A specialized version of `_.sampleSize` for arrays.
  3758. *
  3759. * @private
  3760. * @param {Array} array The array to sample.
  3761. * @param {number} n The number of elements to sample.
  3762. * @returns {Array} Returns the random elements.
  3763. */
  3764. function arraySampleSize(array, n) {
  3765. return shuffleSelf(copyArray(array), baseClamp(n, 0, array.length));
  3766. }
  3767. /**
  3768. * A specialized version of `_.shuffle` for arrays.
  3769. *
  3770. * @private
  3771. * @param {Array} array The array to shuffle.
  3772. * @returns {Array} Returns the new shuffled array.
  3773. */
  3774. function arrayShuffle(array) {
  3775. return shuffleSelf(copyArray(array));
  3776. }
  3777. /**
  3778. * This function is like `assignValue` except that it doesn't assign
  3779. * `undefined` values.
  3780. *
  3781. * @private
  3782. * @param {Object} object The object to modify.
  3783. * @param {string} key The key of the property to assign.
  3784. * @param {*} value The value to assign.
  3785. */
  3786. function assignMergeValue(object, key, value) {
  3787. if ((value !== undefined && !eq(object[key], value)) ||
  3788. (value === undefined && !(key in object))) {
  3789. baseAssignValue(object, key, value);
  3790. }
  3791. }
  3792. /**
  3793. * Assigns `value` to `key` of `object` if the existing value is not equivalent
  3794. * using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
  3795. * for equality comparisons.
  3796. *
  3797. * @private
  3798. * @param {Object} object The object to modify.
  3799. * @param {string} key The key of the property to assign.
  3800. * @param {*} value The value to assign.
  3801. */
  3802. function assignValue(object, key, value) {
  3803. var objValue = object[key];
  3804. if (!(hasOwnProperty.call(object, key) && eq(objValue, value)) ||
  3805. (value === undefined && !(key in object))) {
  3806. baseAssignValue(object, key, value);
  3807. }
  3808. }
  3809. /**
  3810. * Gets the index at which the `key` is found in `array` of key-value pairs.
  3811. *
  3812. * @private
  3813. * @param {Array} array The array to inspect.
  3814. * @param {*} key The key to search for.
  3815. * @returns {number} Returns the index of the matched value, else `-1`.
  3816. */
  3817. function assocIndexOf(array, key) {
  3818. var length = array.length;
  3819. while (length--) {
  3820. if (eq(array[length][0], key)) {
  3821. return length;
  3822. }
  3823. }
  3824. return -1;
  3825. }
  3826. /**
  3827. * Aggregates elements of `collection` on `accumulator` with keys transformed
  3828. * by `iteratee` and values set by `setter`.
  3829. *
  3830. * @private
  3831. * @param {Array|Object} collection The collection to iterate over.
  3832. * @param {Function} setter The function to set `accumulator` values.
  3833. * @param {Function} iteratee The iteratee to transform keys.
  3834. * @param {Object} accumulator The initial aggregated object.
  3835. * @returns {Function} Returns `accumulator`.
  3836. */
  3837. function baseAggregator(collection, setter, iteratee, accumulator) {
  3838. baseEach(collection, function(value, key, collection) {
  3839. setter(accumulator, value, iteratee(value), collection);
  3840. });
  3841. return accumulator;
  3842. }
  3843. /**
  3844. * The base implementation of `_.assign` without support for multiple sources
  3845. * or `customizer` functions.
  3846. *
  3847. * @private
  3848. * @param {Object} object The destination object.
  3849. * @param {Object} source The source object.
  3850. * @returns {Object} Returns `object`.
  3851. */
  3852. function baseAssign(object, source) {
  3853. return object && copyObject(source, keys(source), object);
  3854. }
  3855. /**
  3856. * The base implementation of `_.assignIn` without support for multiple sources
  3857. * or `customizer` functions.
  3858. *
  3859. * @private
  3860. * @param {Object} object The destination object.
  3861. * @param {Object} source The source object.
  3862. * @returns {Object} Returns `object`.
  3863. */
  3864. function baseAssignIn(object, source) {
  3865. return object && copyObject(source, keysIn(source), object);
  3866. }
  3867. /**
  3868. * The base implementation of `assignValue` and `assignMergeValue` without
  3869. * value checks.
  3870. *
  3871. * @private
  3872. * @param {Object} object The object to modify.
  3873. * @param {string} key The key of the property to assign.
  3874. * @param {*} value The value to assign.
  3875. */
  3876. function baseAssignValue(object, key, value) {
  3877. if (key == '__proto__' && defineProperty) {
  3878. defineProperty(object, key, {
  3879. 'configurable': true,
  3880. 'enumerable': true,
  3881. 'value': value,
  3882. 'writable': true
  3883. });
  3884. } else {
  3885. object[key] = value;
  3886. }
  3887. }
  3888. /**
  3889. * The base implementation of `_.at` without support for individual paths.
  3890. *
  3891. * @private
  3892. * @param {Object} object The object to iterate over.
  3893. * @param {string[]} paths The property paths to pick.
  3894. * @returns {Array} Returns the picked elements.
  3895. */
  3896. function baseAt(object, paths) {
  3897. var index = -1,
  3898. length = paths.length,
  3899. result = Array(length),
  3900. skip = object == null;
  3901. while (++index < length) {
  3902. result[index] = skip ? undefined : get(object, paths[index]);
  3903. }
  3904. return result;
  3905. }
  3906. /**
  3907. * The base implementation of `_.clamp` which doesn't coerce arguments.
  3908. *
  3909. * @private
  3910. * @param {number} number The number to clamp.
  3911. * @param {number} [lower] The lower bound.
  3912. * @param {number} upper The upper bound.
  3913. * @returns {number} Returns the clamped number.
  3914. */
  3915. function baseClamp(number, lower, upper) {
  3916. if (number === number) {
  3917. if (upper !== undefined) {
  3918. number = number <= upper ? number : upper;
  3919. }
  3920. if (lower !== undefined) {
  3921. number = number >= lower ? number : lower;
  3922. }
  3923. }
  3924. return number;
  3925. }
  3926. /**
  3927. * The base implementation of `_.clone` and `_.cloneDeep` which tracks
  3928. * traversed objects.
  3929. *
  3930. * @private
  3931. * @param {*} value The value to clone.
  3932. * @param {boolean} bitmask The bitmask flags.
  3933. * 1 - Deep clone
  3934. * 2 - Flatten inherited properties
  3935. * 4 - Clone symbols
  3936. * @param {Function} [customizer] The function to customize cloning.
  3937. * @param {string} [key] The key of `value`.
  3938. * @param {Object} [object] The parent object of `value`.
  3939. * @param {Object} [stack] Tracks traversed objects and their clone counterparts.
  3940. * @returns {*} Returns the cloned value.
  3941. */
  3942. function baseClone(value, bitmask, customizer, key, object, stack) {
  3943. var result,
  3944. isDeep = bitmask & CLONE_DEEP_FLAG,
  3945. isFlat = bitmask & CLONE_FLAT_FLAG,
  3946. isFull = bitmask & CLONE_SYMBOLS_FLAG;
  3947. if (customizer) {
  3948. result = object ? customizer(value, key, object, stack) : customizer(value);
  3949. }
  3950. if (result !== undefined) {
  3951. return result;
  3952. }
  3953. if (!isObject(value)) {
  3954. return value;
  3955. }
  3956. var isArr = isArray(value);
  3957. if (isArr) {
  3958. result = initCloneArray(value);
  3959. if (!isDeep) {
  3960. return copyArray(value, result);
  3961. }
  3962. } else {
  3963. var tag = getTag(value),
  3964. isFunc = tag == funcTag || tag == genTag;
  3965. if (isBuffer(value)) {
  3966. return cloneBuffer(value, isDeep);
  3967. }
  3968. if (tag == objectTag || tag == argsTag || (isFunc && !object)) {
  3969. result = (isFlat || isFunc) ? {} : initCloneObject(value);
  3970. if (!isDeep) {
  3971. return isFlat
  3972. ? copySymbolsIn(value, baseAssignIn(result, value))
  3973. : copySymbols(value, baseAssign(result, value));
  3974. }
  3975. } else {
  3976. if (!cloneableTags[tag]) {
  3977. return object ? value : {};
  3978. }
  3979. result = initCloneByTag(value, tag, isDeep);
  3980. }
  3981. }
  3982. // Check for circular references and return its corresponding clone.
  3983. stack || (stack = new Stack);
  3984. var stacked = stack.get(value);
  3985. if (stacked) {
  3986. return stacked;
  3987. }
  3988. stack.set(value, result);
  3989. if (isSet(value)) {
  3990. value.forEach(function(subValue) {
  3991. result.add(baseClone(subValue, bitmask, customizer, subValue, value, stack));
  3992. });
  3993. } else if (isMap(value)) {
  3994. value.forEach(function(subValue, key) {
  3995. result.set(key, baseClone(subValue, bitmask, customizer, key, value, stack));
  3996. });
  3997. }
  3998. var keysFunc = isFull
  3999. ? (isFlat ? getAllKeysIn : getAllKeys)
  4000. : (isFlat ? keysIn : keys);
  4001. var props = isArr ? undefined : keysFunc(value);
  4002. arrayEach(props || value, function(subValue, key) {
  4003. if (props) {
  4004. key = subValue;
  4005. subValue = value[key];
  4006. }
  4007. // Recursively populate clone (susceptible to call stack limits).
  4008. assignValue(result, key, baseClone(subValue, bitmask, customizer, key, value, stack));
  4009. });
  4010. return result;
  4011. }
  4012. /**
  4013. * The base implementation of `_.conforms` which doesn't clone `source`.
  4014. *
  4015. * @private
  4016. * @param {Object} source The object of property predicates to conform to.
  4017. * @returns {Function} Returns the new spec function.
  4018. */
  4019. function baseConforms(source) {
  4020. var props = keys(source);
  4021. return function(object) {
  4022. return baseConformsTo(object, source, props);
  4023. };
  4024. }
  4025. /**
  4026. * The base implementation of `_.conformsTo` which accepts `props` to check.
  4027. *
  4028. * @private
  4029. * @param {Object} object The object to inspect.
  4030. * @param {Object} source The object of property predicates to conform to.
  4031. * @returns {boolean} Returns `true` if `object` conforms, else `false`.
  4032. */
  4033. function baseConformsTo(object, source, props) {
  4034. var length = props.length;
  4035. if (object == null) {
  4036. return !length;
  4037. }
  4038. object = Object(object);
  4039. while (length--) {
  4040. var key = props[length],
  4041. predicate = source[key],
  4042. value = object[key];
  4043. if ((value === undefined && !(key in object)) || !predicate(value)) {
  4044. return false;
  4045. }
  4046. }
  4047. return true;
  4048. }
  4049. /**
  4050. * The base implementation of `_.delay` and `_.defer` which accepts `args`
  4051. * to provide to `func`.
  4052. *
  4053. * @private
  4054. * @param {Function} func The function to delay.
  4055. * @param {number} wait The number of milliseconds to delay invocation.
  4056. * @param {Array} args The arguments to provide to `func`.
  4057. * @returns {number|Object} Returns the timer id or timeout object.
  4058. */
  4059. function baseDelay(func, wait, args) {
  4060. if (typeof func != 'function') {
  4061. throw new TypeError(FUNC_ERROR_TEXT);
  4062. }
  4063. return setTimeout(function() { func.apply(undefined, args); }, wait);
  4064. }
  4065. /**
  4066. * The base implementation of methods like `_.difference` without support
  4067. * for excluding multiple arrays or iteratee shorthands.
  4068. *
  4069. * @private
  4070. * @param {Array} array The array to inspect.
  4071. * @param {Array} values The values to exclude.
  4072. * @param {Function} [iteratee] The iteratee invoked per element.
  4073. * @param {Function} [comparator] The comparator invoked per element.
  4074. * @returns {Array} Returns the new array of filtered values.
  4075. */
  4076. function baseDifference(array, values, iteratee, comparator) {
  4077. var index = -1,
  4078. includes = arrayIncludes,
  4079. isCommon = true,
  4080. length = array.length,
  4081. result = [],
  4082. valuesLength = values.length;
  4083. if (!length) {
  4084. return result;
  4085. }
  4086. if (iteratee) {
  4087. values = arrayMap(values, baseUnary(iteratee));
  4088. }
  4089. if (comparator) {
  4090. includes = arrayIncludesWith;
  4091. isCommon = false;
  4092. }
  4093. else if (values.length >= LARGE_ARRAY_SIZE) {
  4094. includes = cacheHas;
  4095. isCommon = false;
  4096. values = new SetCache(values);
  4097. }
  4098. outer:
  4099. while (++index < length) {
  4100. var value = array[index],
  4101. computed = iteratee == null ? value : iteratee(value);
  4102. value = (comparator || value !== 0) ? value : 0;
  4103. if (isCommon && computed === computed) {
  4104. var valuesIndex = valuesLength;
  4105. while (valuesIndex--) {
  4106. if (values[valuesIndex] === computed) {
  4107. continue outer;
  4108. }
  4109. }
  4110. result.push(value);
  4111. }
  4112. else if (!includes(values, computed, comparator)) {
  4113. result.push(value);
  4114. }
  4115. }
  4116. return result;
  4117. }
  4118. /**
  4119. * The base implementation of `_.forEach` without support for iteratee shorthands.
  4120. *
  4121. * @private
  4122. * @param {Array|Object} collection The collection to iterate over.
  4123. * @param {Function} iteratee The function invoked per iteration.
  4124. * @returns {Array|Object} Returns `collection`.
  4125. */
  4126. var baseEach = createBaseEach(baseForOwn);
  4127. /**
  4128. * The base implementation of `_.forEachRight` without support for iteratee shorthands.
  4129. *
  4130. * @private
  4131. * @param {Array|Object} collection The collection to iterate over.
  4132. * @param {Function} iteratee The function invoked per iteration.
  4133. * @returns {Array|Object} Returns `collection`.
  4134. */
  4135. var baseEachRight = createBaseEach(baseForOwnRight, true);
  4136. /**
  4137. * The base implementation of `_.every` without support for iteratee shorthands.
  4138. *
  4139. * @private
  4140. * @param {Array|Object} collection The collection to iterate over.
  4141. * @param {Function} predicate The function invoked per iteration.
  4142. * @returns {boolean} Returns `true` if all elements pass the predicate check,
  4143. * else `false`
  4144. */
  4145. function baseEvery(collection, predicate) {
  4146. var result = true;
  4147. baseEach(collection, function(value, index, collection) {
  4148. result = !!predicate(value, index, collection);
  4149. return result;
  4150. });
  4151. return result;
  4152. }
  4153. /**
  4154. * The base implementation of methods like `_.max` and `_.min` which accepts a
  4155. * `comparator` to determine the extremum value.
  4156. *
  4157. * @private
  4158. * @param {Array} array The array to iterate over.
  4159. * @param {Function} iteratee The iteratee invoked per iteration.
  4160. * @param {Function} comparator The comparator used to compare values.
  4161. * @returns {*} Returns the extremum value.
  4162. */
  4163. function baseExtremum(array, iteratee, comparator) {
  4164. var index = -1,
  4165. length = array.length;
  4166. while (++index < length) {
  4167. var value = array[index],
  4168. current = iteratee(value);
  4169. if (current != null && (computed === undefined
  4170. ? (current === current && !isSymbol(current))
  4171. : comparator(current, computed)
  4172. )) {
  4173. var computed = current,
  4174. result = value;
  4175. }
  4176. }
  4177. return result;
  4178. }
  4179. /**
  4180. * The base implementation of `_.fill` without an iteratee call guard.
  4181. *
  4182. * @private
  4183. * @param {Array} array The array to fill.
  4184. * @param {*} value The value to fill `array` with.
  4185. * @param {number} [start=0] The start position.
  4186. * @param {number} [end=array.length] The end position.
  4187. * @returns {Array} Returns `array`.
  4188. */
  4189. function baseFill(array, value, start, end) {
  4190. var length = array.length;
  4191. start = toInteger(start);
  4192. if (start < 0) {
  4193. start = -start > length ? 0 : (length + start);
  4194. }
  4195. end = (end === undefined || end > length) ? length : toInteger(end);
  4196. if (end < 0) {
  4197. end += length;
  4198. }
  4199. end = start > end ? 0 : toLength(end);
  4200. while (start < end) {
  4201. array[start++] = value;
  4202. }
  4203. return array;
  4204. }
  4205. /**
  4206. * The base implementation of `_.filter` without support for iteratee shorthands.
  4207. *
  4208. * @private
  4209. * @param {Array|Object} collection The collection to iterate over.
  4210. * @param {Function} predicate The function invoked per iteration.
  4211. * @returns {Array} Returns the new filtered array.
  4212. */
  4213. function baseFilter(collection, predicate) {
  4214. var result = [];
  4215. baseEach(collection, function(value, index, collection) {
  4216. if (predicate(value, index, collection)) {
  4217. result.push(value);
  4218. }
  4219. });
  4220. return result;
  4221. }
  4222. /**
  4223. * The base implementation of `_.flatten` with support for restricting flattening.
  4224. *
  4225. * @private
  4226. * @param {Array} array The array to flatten.
  4227. * @param {number} depth The maximum recursion depth.
  4228. * @param {boolean} [predicate=isFlattenable] The function invoked per iteration.
  4229. * @param {boolean} [isStrict] Restrict to values that pass `predicate` checks.
  4230. * @param {Array} [result=[]] The initial result value.
  4231. * @returns {Array} Returns the new flattened array.
  4232. */
  4233. function baseFlatten(array, depth, predicate, isStrict, result) {
  4234. var index = -1,
  4235. length = array.length;
  4236. predicate || (predicate = isFlattenable);
  4237. result || (result = []);
  4238. while (++index < length) {
  4239. var value = array[index];
  4240. if (depth > 0 && predicate(value)) {
  4241. if (depth > 1) {
  4242. // Recursively flatten arrays (susceptible to call stack limits).
  4243. baseFlatten(value, depth - 1, predicate, isStrict, result);
  4244. } else {
  4245. arrayPush(result, value);
  4246. }
  4247. } else if (!isStrict) {
  4248. result[result.length] = value;
  4249. }
  4250. }
  4251. return result;
  4252. }
  4253. /**
  4254. * The base implementation of `baseForOwn` which iterates over `object`
  4255. * properties returned by `keysFunc` and invokes `iteratee` for each property.
  4256. * Iteratee functions may exit iteration early by explicitly returning `false`.
  4257. *
  4258. * @private
  4259. * @param {Object} object The object to iterate over.
  4260. * @param {Function} iteratee The function invoked per iteration.
  4261. * @param {Function} keysFunc The function to get the keys of `object`.
  4262. * @returns {Object} Returns `object`.
  4263. */
  4264. var baseFor = createBaseFor();
  4265. /**
  4266. * This function is like `baseFor` except that it iterates over properties
  4267. * in the opposite order.
  4268. *
  4269. * @private
  4270. * @param {Object} object The object to iterate over.
  4271. * @param {Function} iteratee The function invoked per iteration.
  4272. * @param {Function} keysFunc The function to get the keys of `object`.
  4273. * @returns {Object} Returns `object`.
  4274. */
  4275. var baseForRight = createBaseFor(true);
  4276. /**
  4277. * The base implementation of `_.forOwn` without support for iteratee shorthands.
  4278. *
  4279. * @private
  4280. * @param {Object} object The object to iterate over.
  4281. * @param {Function} iteratee The function invoked per iteration.
  4282. * @returns {Object} Returns `object`.
  4283. */
  4284. function baseForOwn(object, iteratee) {
  4285. return object && baseFor(object, iteratee, keys);
  4286. }
  4287. /**
  4288. * The base implementation of `_.forOwnRight` without support for iteratee shorthands.
  4289. *
  4290. * @private
  4291. * @param {Object} object The object to iterate over.
  4292. * @param {Function} iteratee The function invoked per iteration.
  4293. * @returns {Object} Returns `object`.
  4294. */
  4295. function baseForOwnRight(object, iteratee) {
  4296. return object && baseForRight(object, iteratee, keys);
  4297. }
  4298. /**
  4299. * The base implementation of `_.functions` which creates an array of
  4300. * `object` function property names filtered from `props`.
  4301. *
  4302. * @private
  4303. * @param {Object} object The object to inspect.
  4304. * @param {Array} props The property names to filter.
  4305. * @returns {Array} Returns the function names.
  4306. */
  4307. function baseFunctions(object, props) {
  4308. return arrayFilter(props, function(key) {
  4309. return isFunction(object[key]);
  4310. });
  4311. }
  4312. /**
  4313. * The base implementation of `_.get` without support for default values.
  4314. *
  4315. * @private
  4316. * @param {Object} object The object to query.
  4317. * @param {Array|string} path The path of the property to get.
  4318. * @returns {*} Returns the resolved value.
  4319. */
  4320. function baseGet(object, path) {
  4321. path = castPath(path, object);
  4322. var index = 0,
  4323. length = path.length;
  4324. while (object != null && index < length) {
  4325. object = object[toKey(path[index++])];
  4326. }
  4327. return (index && index == length) ? object : undefined;
  4328. }
  4329. /**
  4330. * The base implementation of `getAllKeys` and `getAllKeysIn` which uses
  4331. * `keysFunc` and `symbolsFunc` to get the enumerable property names and
  4332. * symbols of `object`.
  4333. *
  4334. * @private
  4335. * @param {Object} object The object to query.
  4336. * @param {Function} keysFunc The function to get the keys of `object`.
  4337. * @param {Function} symbolsFunc The function to get the symbols of `object`.
  4338. * @returns {Array} Returns the array of property names and symbols.
  4339. */
  4340. function baseGetAllKeys(object, keysFunc, symbolsFunc) {
  4341. var result = keysFunc(object);
  4342. return isArray(object) ? result : arrayPush(result, symbolsFunc(object));
  4343. }
  4344. /**
  4345. * The base implementation of `getTag` without fallbacks for buggy environments.
  4346. *
  4347. * @private
  4348. * @param {*} value The value to query.
  4349. * @returns {string} Returns the `toStringTag`.
  4350. */
  4351. function baseGetTag(value) {
  4352. if (value == null) {
  4353. return value === undefined ? undefinedTag : nullTag;
  4354. }
  4355. return (symToStringTag && symToStringTag in Object(value))
  4356. ? getRawTag(value)
  4357. : objectToString(value);
  4358. }
  4359. /**
  4360. * The base implementation of `_.gt` which doesn't coerce arguments.
  4361. *
  4362. * @private
  4363. * @param {*} value The value to compare.
  4364. * @param {*} other The other value to compare.
  4365. * @returns {boolean} Returns `true` if `value` is greater than `other`,
  4366. * else `false`.
  4367. */
  4368. function baseGt(value, other) {
  4369. return value > other;
  4370. }
  4371. /**
  4372. * The base implementation of `_.has` without support for deep paths.
  4373. *
  4374. * @private
  4375. * @param {Object} [object] The object to query.
  4376. * @param {Array|string} key The key to check.
  4377. * @returns {boolean} Returns `true` if `key` exists, else `false`.
  4378. */
  4379. function baseHas(object, key) {
  4380. return object != null && hasOwnProperty.call(object, key);
  4381. }
  4382. /**
  4383. * The base implementation of `_.hasIn` without support for deep paths.
  4384. *
  4385. * @private
  4386. * @param {Object} [object] The object to query.
  4387. * @param {Array|string} key The key to check.
  4388. * @returns {boolean} Returns `true` if `key` exists, else `false`.
  4389. */
  4390. function baseHasIn(object, key) {
  4391. return object != null && key in Object(object);
  4392. }
  4393. /**
  4394. * The base implementation of `_.inRange` which doesn't coerce arguments.
  4395. *
  4396. * @private
  4397. * @param {number} number The number to check.
  4398. * @param {number} start The start of the range.
  4399. * @param {number} end The end of the range.
  4400. * @returns {boolean} Returns `true` if `number` is in the range, else `false`.
  4401. */
  4402. function baseInRange(number, start, end) {
  4403. return number >= nativeMin(start, end) && number < nativeMax(start, end);
  4404. }
  4405. /**
  4406. * The base implementation of methods like `_.intersection`, without support
  4407. * for iteratee shorthands, that accepts an array of arrays to inspect.
  4408. *
  4409. * @private
  4410. * @param {Array} arrays The arrays to inspect.
  4411. * @param {Function} [iteratee] The iteratee invoked per element.
  4412. * @param {Function} [comparator] The comparator invoked per element.
  4413. * @returns {Array} Returns the new array of shared values.
  4414. */
  4415. function baseIntersection(arrays, iteratee, comparator) {
  4416. var includes = comparator ? arrayIncludesWith : arrayIncludes,
  4417. length = arrays[0].length,
  4418. othLength = arrays.length,
  4419. othIndex = othLength,
  4420. caches = Array(othLength),
  4421. maxLength = Infinity,
  4422. result = [];
  4423. while (othIndex--) {
  4424. var array = arrays[othIndex];
  4425. if (othIndex && iteratee) {
  4426. array = arrayMap(array, baseUnary(iteratee));
  4427. }
  4428. maxLength = nativeMin(array.length, maxLength);
  4429. caches[othIndex] = !comparator && (iteratee || (length >= 120 && array.length >= 120))
  4430. ? new SetCache(othIndex && array)
  4431. : undefined;
  4432. }
  4433. array = arrays[0];
  4434. var index = -1,
  4435. seen = caches[0];
  4436. outer:
  4437. while (++index < length && result.length < maxLength) {
  4438. var value = array[index],
  4439. computed = iteratee ? iteratee(value) : value;
  4440. value = (comparator || value !== 0) ? value : 0;
  4441. if (!(seen
  4442. ? cacheHas(seen, computed)
  4443. : includes(result, computed, comparator)
  4444. )) {
  4445. othIndex = othLength;
  4446. while (--othIndex) {
  4447. var cache = caches[othIndex];
  4448. if (!(cache
  4449. ? cacheHas(cache, computed)
  4450. : includes(arrays[othIndex], computed, comparator))
  4451. ) {
  4452. continue outer;
  4453. }
  4454. }
  4455. if (seen) {
  4456. seen.push(computed);
  4457. }
  4458. result.push(value);
  4459. }
  4460. }
  4461. return result;
  4462. }
  4463. /**
  4464. * The base implementation of `_.invert` and `_.invertBy` which inverts
  4465. * `object` with values transformed by `iteratee` and set by `setter`.
  4466. *
  4467. * @private
  4468. * @param {Object} object The object to iterate over.
  4469. * @param {Function} setter The function to set `accumulator` values.
  4470. * @param {Function} iteratee The iteratee to transform values.
  4471. * @param {Object} accumulator The initial inverted object.
  4472. * @returns {Function} Returns `accumulator`.
  4473. */
  4474. function baseInverter(object, setter, iteratee, accumulator) {
  4475. baseForOwn(object, function(value, key, object) {
  4476. setter(accumulator, iteratee(value), key, object);
  4477. });
  4478. return accumulator;
  4479. }
  4480. /**
  4481. * The base implementation of `_.invoke` without support for individual
  4482. * method arguments.
  4483. *
  4484. * @private
  4485. * @param {Object} object The object to query.
  4486. * @param {Array|string} path The path of the method to invoke.
  4487. * @param {Array} args The arguments to invoke the method with.
  4488. * @returns {*} Returns the result of the invoked method.
  4489. */
  4490. function baseInvoke(object, path, args) {
  4491. path = castPath(path, object);
  4492. object = parent(object, path);
  4493. var func = object == null ? object : object[toKey(last(path))];
  4494. return func == null ? undefined : apply(func, object, args);
  4495. }
  4496. /**
  4497. * The base implementation of `_.isArguments`.
  4498. *
  4499. * @private
  4500. * @param {*} value The value to check.
  4501. * @returns {boolean} Returns `true` if `value` is an `arguments` object,
  4502. */
  4503. function baseIsArguments(value) {
  4504. return isObjectLike(value) && baseGetTag(value) == argsTag;
  4505. }
  4506. /**
  4507. * The base implementation of `_.isArrayBuffer` without Node.js optimizations.
  4508. *
  4509. * @private
  4510. * @param {*} value The value to check.
  4511. * @returns {boolean} Returns `true` if `value` is an array buffer, else `false`.
  4512. */
  4513. function baseIsArrayBuffer(value) {
  4514. return isObjectLike(value) && baseGetTag(value) == arrayBufferTag;
  4515. }
  4516. /**
  4517. * The base implementation of `_.isDate` without Node.js optimizations.
  4518. *
  4519. * @private
  4520. * @param {*} value The value to check.
  4521. * @returns {boolean} Returns `true` if `value` is a date object, else `false`.
  4522. */
  4523. function baseIsDate(value) {
  4524. return isObjectLike(value) && baseGetTag(value) == dateTag;
  4525. }
  4526. /**
  4527. * The base implementation of `_.isEqual` which supports partial comparisons
  4528. * and tracks traversed objects.
  4529. *
  4530. * @private
  4531. * @param {*} value The value to compare.
  4532. * @param {*} other The other value to compare.
  4533. * @param {boolean} bitmask The bitmask flags.
  4534. * 1 - Unordered comparison
  4535. * 2 - Partial comparison
  4536. * @param {Function} [customizer] The function to customize comparisons.
  4537. * @param {Object} [stack] Tracks traversed `value` and `other` objects.
  4538. * @returns {boolean} Returns `true` if the values are equivalent, else `false`.
  4539. */
  4540. function baseIsEqual(value, other, bitmask, customizer, stack) {
  4541. if (value === other) {
  4542. return true;
  4543. }
  4544. if (value == null || other == null || (!isObjectLike(value) && !isObjectLike(other))) {
  4545. return value !== value && other !== other;
  4546. }
  4547. return baseIsEqualDeep(value, other, bitmask, customizer, baseIsEqual, stack);
  4548. }
  4549. /**
  4550. * A specialized version of `baseIsEqual` for arrays and objects which performs
  4551. * deep comparisons and tracks traversed objects enabling objects with circular
  4552. * references to be compared.
  4553. *
  4554. * @private
  4555. * @param {Object} object The object to compare.
  4556. * @param {Object} other The other object to compare.
  4557. * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.
  4558. * @param {Function} customizer The function to customize comparisons.
  4559. * @param {Function} equalFunc The function to determine equivalents of values.
  4560. * @param {Object} [stack] Tracks traversed `object` and `other` objects.
  4561. * @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
  4562. */
  4563. function baseIsEqualDeep(object, other, bitmask, customizer, equalFunc, stack) {
  4564. var objIsArr = isArray(object),
  4565. othIsArr = isArray(other),
  4566. objTag = objIsArr ? arrayTag : getTag(object),
  4567. othTag = othIsArr ? arrayTag : getTag(other);
  4568. objTag = objTag == argsTag ? objectTag : objTag;
  4569. othTag = othTag == argsTag ? objectTag : othTag;
  4570. var objIsObj = objTag == objectTag,
  4571. othIsObj = othTag == objectTag,
  4572. isSameTag = objTag == othTag;
  4573. if (isSameTag && isBuffer(object)) {
  4574. if (!isBuffer(other)) {
  4575. return false;
  4576. }
  4577. objIsArr = true;
  4578. objIsObj = false;
  4579. }
  4580. if (isSameTag && !objIsObj) {
  4581. stack || (stack = new Stack);
  4582. return (objIsArr || isTypedArray(object))
  4583. ? equalArrays(object, other, bitmask, customizer, equalFunc, stack)
  4584. : equalByTag(object, other, objTag, bitmask, customizer, equalFunc, stack);
  4585. }
  4586. if (!(bitmask & COMPARE_PARTIAL_FLAG)) {
  4587. var objIsWrapped = objIsObj && hasOwnProperty.call(object, '__wrapped__'),
  4588. othIsWrapped = othIsObj && hasOwnProperty.call(other, '__wrapped__');
  4589. if (objIsWrapped || othIsWrapped) {
  4590. var objUnwrapped = objIsWrapped ? object.value() : object,
  4591. othUnwrapped = othIsWrapped ? other.value() : other;
  4592. stack || (stack = new Stack);
  4593. return equalFunc(objUnwrapped, othUnwrapped, bitmask, customizer, stack);
  4594. }
  4595. }
  4596. if (!isSameTag) {
  4597. return false;
  4598. }
  4599. stack || (stack = new Stack);
  4600. return equalObjects(object, other, bitmask, customizer, equalFunc, stack);
  4601. }
  4602. /**
  4603. * The base implementation of `_.isMap` without Node.js optimizations.
  4604. *
  4605. * @private
  4606. * @param {*} value The value to check.
  4607. * @returns {boolean} Returns `true` if `value` is a map, else `false`.
  4608. */
  4609. function baseIsMap(value) {
  4610. return isObjectLike(value) && getTag(value) == mapTag;
  4611. }
  4612. /**
  4613. * The base implementation of `_.isMatch` without support for iteratee shorthands.
  4614. *
  4615. * @private
  4616. * @param {Object} object The object to inspect.
  4617. * @param {Object} source The object of property values to match.
  4618. * @param {Array} matchData The property names, values, and compare flags to match.
  4619. * @param {Function} [customizer] The function to customize comparisons.
  4620. * @returns {boolean} Returns `true` if `object` is a match, else `false`.
  4621. */
  4622. function baseIsMatch(object, source, matchData, customizer) {
  4623. var index = matchData.length,
  4624. length = index,
  4625. noCustomizer = !customizer;
  4626. if (object == null) {
  4627. return !length;
  4628. }
  4629. object = Object(object);
  4630. while (index--) {
  4631. var data = matchData[index];
  4632. if ((noCustomizer && data[2])
  4633. ? data[1] !== object[data[0]]
  4634. : !(data[0] in object)
  4635. ) {
  4636. return false;
  4637. }
  4638. }
  4639. while (++index < length) {
  4640. data = matchData[index];
  4641. var key = data[0],
  4642. objValue = object[key],
  4643. srcValue = data[1];
  4644. if (noCustomizer && data[2]) {
  4645. if (objValue === undefined && !(key in object)) {
  4646. return false;
  4647. }
  4648. } else {
  4649. var stack = new Stack;
  4650. if (customizer) {
  4651. var result = customizer(objValue, srcValue, key, object, source, stack);
  4652. }
  4653. if (!(result === undefined
  4654. ? baseIsEqual(srcValue, objValue, COMPARE_PARTIAL_FLAG | COMPARE_UNORDERED_FLAG, customizer, stack)
  4655. : result
  4656. )) {
  4657. return false;
  4658. }
  4659. }
  4660. }
  4661. return true;
  4662. }
  4663. /**
  4664. * The base implementation of `_.isNative` without bad shim checks.
  4665. *
  4666. * @private
  4667. * @param {*} value The value to check.
  4668. * @returns {boolean} Returns `true` if `value` is a native function,
  4669. * else `false`.
  4670. */
  4671. function baseIsNative(value) {
  4672. if (!isObject(value) || isMasked(value)) {
  4673. return false;
  4674. }
  4675. var pattern = isFunction(value) ? reIsNative : reIsHostCtor;
  4676. return pattern.test(toSource(value));
  4677. }
  4678. /**
  4679. * The base implementation of `_.isRegExp` without Node.js optimizations.
  4680. *
  4681. * @private
  4682. * @param {*} value The value to check.
  4683. * @returns {boolean} Returns `true` if `value` is a regexp, else `false`.
  4684. */
  4685. function baseIsRegExp(value) {
  4686. return isObjectLike(value) && baseGetTag(value) == regexpTag;
  4687. }
  4688. /**
  4689. * The base implementation of `_.isSet` without Node.js optimizations.
  4690. *
  4691. * @private
  4692. * @param {*} value The value to check.
  4693. * @returns {boolean} Returns `true` if `value` is a set, else `false`.
  4694. */
  4695. function baseIsSet(value) {
  4696. return isObjectLike(value) && getTag(value) == setTag;
  4697. }
  4698. /**
  4699. * The base implementation of `_.isTypedArray` without Node.js optimizations.
  4700. *
  4701. * @private
  4702. * @param {*} value The value to check.
  4703. * @returns {boolean} Returns `true` if `value` is a typed array, else `false`.
  4704. */
  4705. function baseIsTypedArray(value) {
  4706. return isObjectLike(value) &&
  4707. isLength(value.length) && !!typedArrayTags[baseGetTag(value)];
  4708. }
  4709. /**
  4710. * The base implementation of `_.iteratee`.
  4711. *
  4712. * @private
  4713. * @param {*} [value=_.identity] The value to convert to an iteratee.
  4714. * @returns {Function} Returns the iteratee.
  4715. */
  4716. function baseIteratee(value) {
  4717. // Don't store the `typeof` result in a variable to avoid a JIT bug in Safari 9.
  4718. // See https://bugs.webkit.org/show_bug.cgi?id=156034 for more details.
  4719. if (typeof value == 'function') {
  4720. return value;
  4721. }
  4722. if (value == null) {
  4723. return identity;
  4724. }
  4725. if (typeof value == 'object') {
  4726. return isArray(value)
  4727. ? baseMatchesProperty(value[0], value[1])
  4728. : baseMatches(value);
  4729. }
  4730. return property(value);
  4731. }
  4732. /**
  4733. * The base implementation of `_.keys` which doesn't treat sparse arrays as dense.
  4734. *
  4735. * @private
  4736. * @param {Object} object The object to query.
  4737. * @returns {Array} Returns the array of property names.
  4738. */
  4739. function baseKeys(object) {
  4740. if (!isPrototype(object)) {
  4741. return nativeKeys(object);
  4742. }
  4743. var result = [];
  4744. for (var key in Object(object)) {
  4745. if (hasOwnProperty.call(object, key) && key != 'constructor') {
  4746. result.push(key);
  4747. }
  4748. }
  4749. return result;
  4750. }
  4751. /**
  4752. * The base implementation of `_.keysIn` which doesn't treat sparse arrays as dense.
  4753. *
  4754. * @private
  4755. * @param {Object} object The object to query.
  4756. * @returns {Array} Returns the array of property names.
  4757. */
  4758. function baseKeysIn(object) {
  4759. if (!isObject(object)) {
  4760. return nativeKeysIn(object);
  4761. }
  4762. var isProto = isPrototype(object),
  4763. result = [];
  4764. for (var key in object) {
  4765. if (!(key == 'constructor' && (isProto || !hasOwnProperty.call(object, key)))) {
  4766. result.push(key);
  4767. }
  4768. }
  4769. return result;
  4770. }
  4771. /**
  4772. * The base implementation of `_.lt` which doesn't coerce arguments.
  4773. *
  4774. * @private
  4775. * @param {*} value The value to compare.
  4776. * @param {*} other The other value to compare.
  4777. * @returns {boolean} Returns `true` if `value` is less than `other`,
  4778. * else `false`.
  4779. */
  4780. function baseLt(value, other) {
  4781. return value < other;
  4782. }
  4783. /**
  4784. * The base implementation of `_.map` without support for iteratee shorthands.
  4785. *
  4786. * @private
  4787. * @param {Array|Object} collection The collection to iterate over.
  4788. * @param {Function} iteratee The function invoked per iteration.
  4789. * @returns {Array} Returns the new mapped array.
  4790. */
  4791. function baseMap(collection, iteratee) {
  4792. var index = -1,
  4793. result = isArrayLike(collection) ? Array(collection.length) : [];
  4794. baseEach(collection, function(value, key, collection) {
  4795. result[++index] = iteratee(value, key, collection);
  4796. });
  4797. return result;
  4798. }
  4799. /**
  4800. * The base implementation of `_.matches` which doesn't clone `source`.
  4801. *
  4802. * @private
  4803. * @param {Object} source The object of property values to match.
  4804. * @returns {Function} Returns the new spec function.
  4805. */
  4806. function baseMatches(source) {
  4807. var matchData = getMatchData(source);
  4808. if (matchData.length == 1 && matchData[0][2]) {
  4809. return matchesStrictComparable(matchData[0][0], matchData[0][1]);
  4810. }
  4811. return function(object) {
  4812. return object === source || baseIsMatch(object, source, matchData);
  4813. };
  4814. }
  4815. /**
  4816. * The base implementation of `_.matchesProperty` which doesn't clone `srcValue`.
  4817. *
  4818. * @private
  4819. * @param {string} path The path of the property to get.
  4820. * @param {*} srcValue The value to match.
  4821. * @returns {Function} Returns the new spec function.
  4822. */
  4823. function baseMatchesProperty(path, srcValue) {
  4824. if (isKey(path) && isStrictComparable(srcValue)) {
  4825. return matchesStrictComparable(toKey(path), srcValue);
  4826. }
  4827. return function(object) {
  4828. var objValue = get(object, path);
  4829. return (objValue === undefined && objValue === srcValue)
  4830. ? hasIn(object, path)
  4831. : baseIsEqual(srcValue, objValue, COMPARE_PARTIAL_FLAG | COMPARE_UNORDERED_FLAG);
  4832. };
  4833. }
  4834. /**
  4835. * The base implementation of `_.merge` without support for multiple sources.
  4836. *
  4837. * @private
  4838. * @param {Object} object The destination object.
  4839. * @param {Object} source The source object.
  4840. * @param {number} srcIndex The index of `source`.
  4841. * @param {Function} [customizer] The function to customize merged values.
  4842. * @param {Object} [stack] Tracks traversed source values and their merged
  4843. * counterparts.
  4844. */
  4845. function baseMerge(object, source, srcIndex, customizer, stack) {
  4846. if (object === source) {
  4847. return;
  4848. }
  4849. baseFor(source, function(srcValue, key) {
  4850. stack || (stack = new Stack);
  4851. if (isObject(srcValue)) {
  4852. baseMergeDeep(object, source, key, srcIndex, baseMerge, customizer, stack);
  4853. }
  4854. else {
  4855. var newValue = customizer
  4856. ? customizer(safeGet(object, key), srcValue, (key + ''), object, source, stack)
  4857. : undefined;
  4858. if (newValue === undefined) {
  4859. newValue = srcValue;
  4860. }
  4861. assignMergeValue(object, key, newValue);
  4862. }
  4863. }, keysIn);
  4864. }
  4865. /**
  4866. * A specialized version of `baseMerge` for arrays and objects which performs
  4867. * deep merges and tracks traversed objects enabling objects with circular
  4868. * references to be merged.
  4869. *
  4870. * @private
  4871. * @param {Object} object The destination object.
  4872. * @param {Object} source The source object.
  4873. * @param {string} key The key of the value to merge.
  4874. * @param {number} srcIndex The index of `source`.
  4875. * @param {Function} mergeFunc The function to merge values.
  4876. * @param {Function} [customizer] The function to customize assigned values.
  4877. * @param {Object} [stack] Tracks traversed source values and their merged
  4878. * counterparts.
  4879. */
  4880. function baseMergeDeep(object, source, key, srcIndex, mergeFunc, customizer, stack) {
  4881. var objValue = safeGet(object, key),
  4882. srcValue = safeGet(source, key),
  4883. stacked = stack.get(srcValue);
  4884. if (stacked) {
  4885. assignMergeValue(object, key, stacked);
  4886. return;
  4887. }
  4888. var newValue = customizer
  4889. ? customizer(objValue, srcValue, (key + ''), object, source, stack)
  4890. : undefined;
  4891. var isCommon = newValue === undefined;
  4892. if (isCommon) {
  4893. var isArr = isArray(srcValue),
  4894. isBuff = !isArr && isBuffer(srcValue),
  4895. isTyped = !isArr && !isBuff && isTypedArray(srcValue);
  4896. newValue = srcValue;
  4897. if (isArr || isBuff || isTyped) {
  4898. if (isArray(objValue)) {
  4899. newValue = objValue;
  4900. }
  4901. else if (isArrayLikeObject(objValue)) {
  4902. newValue = copyArray(objValue);
  4903. }
  4904. else if (isBuff) {
  4905. isCommon = false;
  4906. newValue = cloneBuffer(srcValue, true);
  4907. }
  4908. else if (isTyped) {
  4909. isCommon = false;
  4910. newValue = cloneTypedArray(srcValue, true);
  4911. }
  4912. else {
  4913. newValue = [];
  4914. }
  4915. }
  4916. else if (isPlainObject(srcValue) || isArguments(srcValue)) {
  4917. newValue = objValue;
  4918. if (isArguments(objValue)) {
  4919. newValue = toPlainObject(objValue);
  4920. }
  4921. else if (!isObject(objValue) || isFunction(objValue)) {
  4922. newValue = initCloneObject(srcValue);
  4923. }
  4924. }
  4925. else {
  4926. isCommon = false;
  4927. }
  4928. }
  4929. if (isCommon) {
  4930. // Recursively merge objects and arrays (susceptible to call stack limits).
  4931. stack.set(srcValue, newValue);
  4932. mergeFunc(newValue, srcValue, srcIndex, customizer, stack);
  4933. stack['delete'](srcValue);
  4934. }
  4935. assignMergeValue(object, key, newValue);
  4936. }
  4937. /**
  4938. * The base implementation of `_.nth` which doesn't coerce arguments.
  4939. *
  4940. * @private
  4941. * @param {Array} array The array to query.
  4942. * @param {number} n The index of the element to return.
  4943. * @returns {*} Returns the nth element of `array`.
  4944. */
  4945. function baseNth(array, n) {
  4946. var length = array.length;
  4947. if (!length) {
  4948. return;
  4949. }
  4950. n += n < 0 ? length : 0;
  4951. return isIndex(n, length) ? array[n] : undefined;
  4952. }
  4953. /**
  4954. * The base implementation of `_.orderBy` without param guards.
  4955. *
  4956. * @private
  4957. * @param {Array|Object} collection The collection to iterate over.
  4958. * @param {Function[]|Object[]|string[]} iteratees The iteratees to sort by.
  4959. * @param {string[]} orders The sort orders of `iteratees`.
  4960. * @returns {Array} Returns the new sorted array.
  4961. */
  4962. function baseOrderBy(collection, iteratees, orders) {
  4963. if (iteratees.length) {
  4964. iteratees = arrayMap(iteratees, function(iteratee) {
  4965. if (isArray(iteratee)) {
  4966. return function(value) {
  4967. return baseGet(value, iteratee.length === 1 ? iteratee[0] : iteratee);
  4968. }
  4969. }
  4970. return iteratee;
  4971. });
  4972. } else {
  4973. iteratees = [identity];
  4974. }
  4975. var index = -1;
  4976. iteratees = arrayMap(iteratees, baseUnary(getIteratee()));
  4977. var result = baseMap(collection, function(value, key, collection) {
  4978. var criteria = arrayMap(iteratees, function(iteratee) {
  4979. return iteratee(value);
  4980. });
  4981. return { 'criteria': criteria, 'index': ++index, 'value': value };
  4982. });
  4983. return baseSortBy(result, function(object, other) {
  4984. return compareMultiple(object, other, orders);
  4985. });
  4986. }
  4987. /**
  4988. * The base implementation of `_.pick` without support for individual
  4989. * property identifiers.
  4990. *
  4991. * @private
  4992. * @param {Object} object The source object.
  4993. * @param {string[]} paths The property paths to pick.
  4994. * @returns {Object} Returns the new object.
  4995. */
  4996. function basePick(object, paths) {
  4997. return basePickBy(object, paths, function(value, path) {
  4998. return hasIn(object, path);
  4999. });
  5000. }
  5001. /**
  5002. * The base implementation of `_.pickBy` without support for iteratee shorthands.
  5003. *
  5004. * @private
  5005. * @param {Object} object The source object.
  5006. * @param {string[]} paths The property paths to pick.
  5007. * @param {Function} predicate The function invoked per property.
  5008. * @returns {Object} Returns the new object.
  5009. */
  5010. function basePickBy(object, paths, predicate) {
  5011. var index = -1,
  5012. length = paths.length,
  5013. result = {};
  5014. while (++index < length) {
  5015. var path = paths[index],
  5016. value = baseGet(object, path);
  5017. if (predicate(value, path)) {
  5018. baseSet(result, castPath(path, object), value);
  5019. }
  5020. }
  5021. return result;
  5022. }
  5023. /**
  5024. * A specialized version of `baseProperty` which supports deep paths.
  5025. *
  5026. * @private
  5027. * @param {Array|string} path The path of the property to get.
  5028. * @returns {Function} Returns the new accessor function.
  5029. */
  5030. function basePropertyDeep(path) {
  5031. return function(object) {
  5032. return baseGet(object, path);
  5033. };
  5034. }
  5035. /**
  5036. * The base implementation of `_.pullAllBy` without support for iteratee
  5037. * shorthands.
  5038. *
  5039. * @private
  5040. * @param {Array} array The array to modify.
  5041. * @param {Array} values The values to remove.
  5042. * @param {Function} [iteratee] The iteratee invoked per element.
  5043. * @param {Function} [comparator] The comparator invoked per element.
  5044. * @returns {Array} Returns `array`.
  5045. */
  5046. function basePullAll(array, values, iteratee, comparator) {
  5047. var indexOf = comparator ? baseIndexOfWith : baseIndexOf,
  5048. index = -1,
  5049. length = values.length,
  5050. seen = array;
  5051. if (array === values) {
  5052. values = copyArray(values);
  5053. }
  5054. if (iteratee) {
  5055. seen = arrayMap(array, baseUnary(iteratee));
  5056. }
  5057. while (++index < length) {
  5058. var fromIndex = 0,
  5059. value = values[index],
  5060. computed = iteratee ? iteratee(value) : value;
  5061. while ((fromIndex = indexOf(seen, computed, fromIndex, comparator)) > -1) {
  5062. if (seen !== array) {
  5063. splice.call(seen, fromIndex, 1);
  5064. }
  5065. splice.call(array, fromIndex, 1);
  5066. }
  5067. }
  5068. return array;
  5069. }
  5070. /**
  5071. * The base implementation of `_.pullAt` without support for individual
  5072. * indexes or capturing the removed elements.
  5073. *
  5074. * @private
  5075. * @param {Array} array The array to modify.
  5076. * @param {number[]} indexes The indexes of elements to remove.
  5077. * @returns {Array} Returns `array`.
  5078. */
  5079. function basePullAt(array, indexes) {
  5080. var length = array ? indexes.length : 0,
  5081. lastIndex = length - 1;
  5082. while (length--) {
  5083. var index = indexes[length];
  5084. if (length == lastIndex || index !== previous) {
  5085. var previous = index;
  5086. if (isIndex(index)) {
  5087. splice.call(array, index, 1);
  5088. } else {
  5089. baseUnset(array, index);
  5090. }
  5091. }
  5092. }
  5093. return array;
  5094. }
  5095. /**
  5096. * The base implementation of `_.random` without support for returning
  5097. * floating-point numbers.
  5098. *
  5099. * @private
  5100. * @param {number} lower The lower bound.
  5101. * @param {number} upper The upper bound.
  5102. * @returns {number} Returns the random number.
  5103. */
  5104. function baseRandom(lower, upper) {
  5105. return lower + nativeFloor(nativeRandom() * (upper - lower + 1));
  5106. }
  5107. /**
  5108. * The base implementation of `_.range` and `_.rangeRight` which doesn't
  5109. * coerce arguments.
  5110. *
  5111. * @private
  5112. * @param {number} start The start of the range.
  5113. * @param {number} end The end of the range.
  5114. * @param {number} step The value to increment or decrement by.
  5115. * @param {boolean} [fromRight] Specify iterating from right to left.
  5116. * @returns {Array} Returns the range of numbers.
  5117. */
  5118. function baseRange(start, end, step, fromRight) {
  5119. var index = -1,
  5120. length = nativeMax(nativeCeil((end - start) / (step || 1)), 0),
  5121. result = Array(length);
  5122. while (length--) {
  5123. result[fromRight ? length : ++index] = start;
  5124. start += step;
  5125. }
  5126. return result;
  5127. }
  5128. /**
  5129. * The base implementation of `_.repeat` which doesn't coerce arguments.
  5130. *
  5131. * @private
  5132. * @param {string} string The string to repeat.
  5133. * @param {number} n The number of times to repeat the string.
  5134. * @returns {string} Returns the repeated string.
  5135. */
  5136. function baseRepeat(string, n) {
  5137. var result = '';
  5138. if (!string || n < 1 || n > MAX_SAFE_INTEGER) {
  5139. return result;
  5140. }
  5141. // Leverage the exponentiation by squaring algorithm for a faster repeat.
  5142. // See https://en.wikipedia.org/wiki/Exponentiation_by_squaring for more details.
  5143. do {
  5144. if (n % 2) {
  5145. result += string;
  5146. }
  5147. n = nativeFloor(n / 2);
  5148. if (n) {
  5149. string += string;
  5150. }
  5151. } while (n);
  5152. return result;
  5153. }
  5154. /**
  5155. * The base implementation of `_.rest` which doesn't validate or coerce arguments.
  5156. *
  5157. * @private
  5158. * @param {Function} func The function to apply a rest parameter to.
  5159. * @param {number} [start=func.length-1] The start position of the rest parameter.
  5160. * @returns {Function} Returns the new function.
  5161. */
  5162. function baseRest(func, start) {
  5163. return setToString(overRest(func, start, identity), func + '');
  5164. }
  5165. /**
  5166. * The base implementation of `_.sample`.
  5167. *
  5168. * @private
  5169. * @param {Array|Object} collection The collection to sample.
  5170. * @returns {*} Returns the random element.
  5171. */
  5172. function baseSample(collection) {
  5173. return arraySample(values(collection));
  5174. }
  5175. /**
  5176. * The base implementation of `_.sampleSize` without param guards.
  5177. *
  5178. * @private
  5179. * @param {Array|Object} collection The collection to sample.
  5180. * @param {number} n The number of elements to sample.
  5181. * @returns {Array} Returns the random elements.
  5182. */
  5183. function baseSampleSize(collection, n) {
  5184. var array = values(collection);
  5185. return shuffleSelf(array, baseClamp(n, 0, array.length));
  5186. }
  5187. /**
  5188. * The base implementation of `_.set`.
  5189. *
  5190. * @private
  5191. * @param {Object} object The object to modify.
  5192. * @param {Array|string} path The path of the property to set.
  5193. * @param {*} value The value to set.
  5194. * @param {Function} [customizer] The function to customize path creation.
  5195. * @returns {Object} Returns `object`.
  5196. */
  5197. function baseSet(object, path, value, customizer) {
  5198. if (!isObject(object)) {
  5199. return object;
  5200. }
  5201. path = castPath(path, object);
  5202. var index = -1,
  5203. length = path.length,
  5204. lastIndex = length - 1,
  5205. nested = object;
  5206. while (nested != null && ++index < length) {
  5207. var key = toKey(path[index]),
  5208. newValue = value;
  5209. if (key === '__proto__' || key === 'constructor' || key === 'prototype') {
  5210. return object;
  5211. }
  5212. if (index != lastIndex) {
  5213. var objValue = nested[key];
  5214. newValue = customizer ? customizer(objValue, key, nested) : undefined;
  5215. if (newValue === undefined) {
  5216. newValue = isObject(objValue)
  5217. ? objValue
  5218. : (isIndex(path[index + 1]) ? [] : {});
  5219. }
  5220. }
  5221. assignValue(nested, key, newValue);
  5222. nested = nested[key];
  5223. }
  5224. return object;
  5225. }
  5226. /**
  5227. * The base implementation of `setData` without support for hot loop shorting.
  5228. *
  5229. * @private
  5230. * @param {Function} func The function to associate metadata with.
  5231. * @param {*} data The metadata.
  5232. * @returns {Function} Returns `func`.
  5233. */
  5234. var baseSetData = !metaMap ? identity : function(func, data) {
  5235. metaMap.set(func, data);
  5236. return func;
  5237. };
  5238. /**
  5239. * The base implementation of `setToString` without support for hot loop shorting.
  5240. *
  5241. * @private
  5242. * @param {Function} func The function to modify.
  5243. * @param {Function} string The `toString` result.
  5244. * @returns {Function} Returns `func`.
  5245. */
  5246. var baseSetToString = !defineProperty ? identity : function(func, string) {
  5247. return defineProperty(func, 'toString', {
  5248. 'configurable': true,
  5249. 'enumerable': false,
  5250. 'value': constant(string),
  5251. 'writable': true
  5252. });
  5253. };
  5254. /**
  5255. * The base implementation of `_.shuffle`.
  5256. *
  5257. * @private
  5258. * @param {Array|Object} collection The collection to shuffle.
  5259. * @returns {Array} Returns the new shuffled array.
  5260. */
  5261. function baseShuffle(collection) {
  5262. return shuffleSelf(values(collection));
  5263. }
  5264. /**
  5265. * The base implementation of `_.slice` without an iteratee call guard.
  5266. *
  5267. * @private
  5268. * @param {Array} array The array to slice.
  5269. * @param {number} [start=0] The start position.
  5270. * @param {number} [end=array.length] The end position.
  5271. * @returns {Array} Returns the slice of `array`.
  5272. */
  5273. function baseSlice(array, start, end) {
  5274. var index = -1,
  5275. length = array.length;
  5276. if (start < 0) {
  5277. start = -start > length ? 0 : (length + start);
  5278. }
  5279. end = end > length ? length : end;
  5280. if (end < 0) {
  5281. end += length;
  5282. }
  5283. length = start > end ? 0 : ((end - start) >>> 0);
  5284. start >>>= 0;
  5285. var result = Array(length);
  5286. while (++index < length) {
  5287. result[index] = array[index + start];
  5288. }
  5289. return result;
  5290. }
  5291. /**
  5292. * The base implementation of `_.some` without support for iteratee shorthands.
  5293. *
  5294. * @private
  5295. * @param {Array|Object} collection The collection to iterate over.
  5296. * @param {Function} predicate The function invoked per iteration.
  5297. * @returns {boolean} Returns `true` if any element passes the predicate check,
  5298. * else `false`.
  5299. */
  5300. function baseSome(collection, predicate) {
  5301. var result;
  5302. baseEach(collection, function(value, index, collection) {
  5303. result = predicate(value, index, collection);
  5304. return !result;
  5305. });
  5306. return !!result;
  5307. }
  5308. /**
  5309. * The base implementation of `_.sortedIndex` and `_.sortedLastIndex` which
  5310. * performs a binary search of `array` to determine the index at which `value`
  5311. * should be inserted into `array` in order to maintain its sort order.
  5312. *
  5313. * @private
  5314. * @param {Array} array The sorted array to inspect.
  5315. * @param {*} value The value to evaluate.
  5316. * @param {boolean} [retHighest] Specify returning the highest qualified index.
  5317. * @returns {number} Returns the index at which `value` should be inserted
  5318. * into `array`.
  5319. */
  5320. function baseSortedIndex(array, value, retHighest) {
  5321. var low = 0,
  5322. high = array == null ? low : array.length;
  5323. if (typeof value == 'number' && value === value && high <= HALF_MAX_ARRAY_LENGTH) {
  5324. while (low < high) {
  5325. var mid = (low + high) >>> 1,
  5326. computed = array[mid];
  5327. if (computed !== null && !isSymbol(computed) &&
  5328. (retHighest ? (computed <= value) : (computed < value))) {
  5329. low = mid + 1;
  5330. } else {
  5331. high = mid;
  5332. }
  5333. }
  5334. return high;
  5335. }
  5336. return baseSortedIndexBy(array, value, identity, retHighest);
  5337. }
  5338. /**
  5339. * The base implementation of `_.sortedIndexBy` and `_.sortedLastIndexBy`
  5340. * which invokes `iteratee` for `value` and each element of `array` to compute
  5341. * their sort ranking. The iteratee is invoked with one argument; (value).
  5342. *
  5343. * @private
  5344. * @param {Array} array The sorted array to inspect.
  5345. * @param {*} value The value to evaluate.
  5346. * @param {Function} iteratee The iteratee invoked per element.
  5347. * @param {boolean} [retHighest] Specify returning the highest qualified index.
  5348. * @returns {number} Returns the index at which `value` should be inserted
  5349. * into `array`.
  5350. */
  5351. function baseSortedIndexBy(array, value, iteratee, retHighest) {
  5352. var low = 0,
  5353. high = array == null ? 0 : array.length;
  5354. if (high === 0) {
  5355. return 0;
  5356. }
  5357. value = iteratee(value);
  5358. var valIsNaN = value !== value,
  5359. valIsNull = value === null,
  5360. valIsSymbol = isSymbol(value),
  5361. valIsUndefined = value === undefined;
  5362. while (low < high) {
  5363. var mid = nativeFloor((low + high) / 2),
  5364. computed = iteratee(array[mid]),
  5365. othIsDefined = computed !== undefined,
  5366. othIsNull = computed === null,
  5367. othIsReflexive = computed === computed,
  5368. othIsSymbol = isSymbol(computed);
  5369. if (valIsNaN) {
  5370. var setLow = retHighest || othIsReflexive;
  5371. } else if (valIsUndefined) {
  5372. setLow = othIsReflexive && (retHighest || othIsDefined);
  5373. } else if (valIsNull) {
  5374. setLow = othIsReflexive && othIsDefined && (retHighest || !othIsNull);
  5375. } else if (valIsSymbol) {
  5376. setLow = othIsReflexive && othIsDefined && !othIsNull && (retHighest || !othIsSymbol);
  5377. } else if (othIsNull || othIsSymbol) {
  5378. setLow = false;
  5379. } else {
  5380. setLow = retHighest ? (computed <= value) : (computed < value);
  5381. }
  5382. if (setLow) {
  5383. low = mid + 1;
  5384. } else {
  5385. high = mid;
  5386. }
  5387. }
  5388. return nativeMin(high, MAX_ARRAY_INDEX);
  5389. }
  5390. /**
  5391. * The base implementation of `_.sortedUniq` and `_.sortedUniqBy` without
  5392. * support for iteratee shorthands.
  5393. *
  5394. * @private
  5395. * @param {Array} array The array to inspect.
  5396. * @param {Function} [iteratee] The iteratee invoked per element.
  5397. * @returns {Array} Returns the new duplicate free array.
  5398. */
  5399. function baseSortedUniq(array, iteratee) {
  5400. var index = -1,
  5401. length = array.length,
  5402. resIndex = 0,
  5403. result = [];
  5404. while (++index < length) {
  5405. var value = array[index],
  5406. computed = iteratee ? iteratee(value) : value;
  5407. if (!index || !eq(computed, seen)) {
  5408. var seen = computed;
  5409. result[resIndex++] = value === 0 ? 0 : value;
  5410. }
  5411. }
  5412. return result;
  5413. }
  5414. /**
  5415. * The base implementation of `_.toNumber` which doesn't ensure correct
  5416. * conversions of binary, hexadecimal, or octal string values.
  5417. *
  5418. * @private
  5419. * @param {*} value The value to process.
  5420. * @returns {number} Returns the number.
  5421. */
  5422. function baseToNumber(value) {
  5423. if (typeof value == 'number') {
  5424. return value;
  5425. }
  5426. if (isSymbol(value)) {
  5427. return NAN;
  5428. }
  5429. return +value;
  5430. }
  5431. /**
  5432. * The base implementation of `_.toString` which doesn't convert nullish
  5433. * values to empty strings.
  5434. *
  5435. * @private
  5436. * @param {*} value The value to process.
  5437. * @returns {string} Returns the string.
  5438. */
  5439. function baseToString(value) {
  5440. // Exit early for strings to avoid a performance hit in some environments.
  5441. if (typeof value == 'string') {
  5442. return value;
  5443. }
  5444. if (isArray(value)) {
  5445. // Recursively convert values (susceptible to call stack limits).
  5446. return arrayMap(value, baseToString) + '';
  5447. }
  5448. if (isSymbol(value)) {
  5449. return symbolToString ? symbolToString.call(value) : '';
  5450. }
  5451. var result = (value + '');
  5452. return (result == '0' && (1 / value) == -INFINITY) ? '-0' : result;
  5453. }
  5454. /**
  5455. * The base implementation of `_.uniqBy` without support for iteratee shorthands.
  5456. *
  5457. * @private
  5458. * @param {Array} array The array to inspect.
  5459. * @param {Function} [iteratee] The iteratee invoked per element.
  5460. * @param {Function} [comparator] The comparator invoked per element.
  5461. * @returns {Array} Returns the new duplicate free array.
  5462. */
  5463. function baseUniq(array, iteratee, comparator) {
  5464. var index = -1,
  5465. includes = arrayIncludes,
  5466. length = array.length,
  5467. isCommon = true,
  5468. result = [],
  5469. seen = result;
  5470. if (comparator) {
  5471. isCommon = false;
  5472. includes = arrayIncludesWith;
  5473. }
  5474. else if (length >= LARGE_ARRAY_SIZE) {
  5475. var set = iteratee ? null : createSet(array);
  5476. if (set) {
  5477. return setToArray(set);
  5478. }
  5479. isCommon = false;
  5480. includes = cacheHas;
  5481. seen = new SetCache;
  5482. }
  5483. else {
  5484. seen = iteratee ? [] : result;
  5485. }
  5486. outer:
  5487. while (++index < length) {
  5488. var value = array[index],
  5489. computed = iteratee ? iteratee(value) : value;
  5490. value = (comparator || value !== 0) ? value : 0;
  5491. if (isCommon && computed === computed) {
  5492. var seenIndex = seen.length;
  5493. while (seenIndex--) {
  5494. if (seen[seenIndex] === computed) {
  5495. continue outer;
  5496. }
  5497. }
  5498. if (iteratee) {
  5499. seen.push(computed);
  5500. }
  5501. result.push(value);
  5502. }
  5503. else if (!includes(seen, computed, comparator)) {
  5504. if (seen !== result) {
  5505. seen.push(computed);
  5506. }
  5507. result.push(value);
  5508. }
  5509. }
  5510. return result;
  5511. }
  5512. /**
  5513. * The base implementation of `_.unset`.
  5514. *
  5515. * @private
  5516. * @param {Object} object The object to modify.
  5517. * @param {Array|string} path The property path to unset.
  5518. * @returns {boolean} Returns `true` if the property is deleted, else `false`.
  5519. */
  5520. function baseUnset(object, path) {
  5521. path = castPath(path, object);
  5522. object = parent(object, path);
  5523. return object == null || delete object[toKey(last(path))];
  5524. }
  5525. /**
  5526. * The base implementation of `_.update`.
  5527. *
  5528. * @private
  5529. * @param {Object} object The object to modify.
  5530. * @param {Array|string} path The path of the property to update.
  5531. * @param {Function} updater The function to produce the updated value.
  5532. * @param {Function} [customizer] The function to customize path creation.
  5533. * @returns {Object} Returns `object`.
  5534. */
  5535. function baseUpdate(object, path, updater, customizer) {
  5536. return baseSet(object, path, updater(baseGet(object, path)), customizer);
  5537. }
  5538. /**
  5539. * The base implementation of methods like `_.dropWhile` and `_.takeWhile`
  5540. * without support for iteratee shorthands.
  5541. *
  5542. * @private
  5543. * @param {Array} array The array to query.
  5544. * @param {Function} predicate The function invoked per iteration.
  5545. * @param {boolean} [isDrop] Specify dropping elements instead of taking them.
  5546. * @param {boolean} [fromRight] Specify iterating from right to left.
  5547. * @returns {Array} Returns the slice of `array`.
  5548. */
  5549. function baseWhile(array, predicate, isDrop, fromRight) {
  5550. var length = array.length,
  5551. index = fromRight ? length : -1;
  5552. while ((fromRight ? index-- : ++index < length) &&
  5553. predicate(array[index], index, array)) {}
  5554. return isDrop
  5555. ? baseSlice(array, (fromRight ? 0 : index), (fromRight ? index + 1 : length))
  5556. : baseSlice(array, (fromRight ? index + 1 : 0), (fromRight ? length : index));
  5557. }
  5558. /**
  5559. * The base implementation of `wrapperValue` which returns the result of
  5560. * performing a sequence of actions on the unwrapped `value`, where each
  5561. * successive action is supplied the return value of the previous.
  5562. *
  5563. * @private
  5564. * @param {*} value The unwrapped value.
  5565. * @param {Array} actions Actions to perform to resolve the unwrapped value.
  5566. * @returns {*} Returns the resolved value.
  5567. */
  5568. function baseWrapperValue(value, actions) {
  5569. var result = value;
  5570. if (result instanceof LazyWrapper) {
  5571. result = result.value();
  5572. }
  5573. return arrayReduce(actions, function(result, action) {
  5574. return action.func.apply(action.thisArg, arrayPush([result], action.args));
  5575. }, result);
  5576. }
  5577. /**
  5578. * The base implementation of methods like `_.xor`, without support for
  5579. * iteratee shorthands, that accepts an array of arrays to inspect.
  5580. *
  5581. * @private
  5582. * @param {Array} arrays The arrays to inspect.
  5583. * @param {Function} [iteratee] The iteratee invoked per element.
  5584. * @param {Function} [comparator] The comparator invoked per element.
  5585. * @returns {Array} Returns the new array of values.
  5586. */
  5587. function baseXor(arrays, iteratee, comparator) {
  5588. var length = arrays.length;
  5589. if (length < 2) {
  5590. return length ? baseUniq(arrays[0]) : [];
  5591. }
  5592. var index = -1,
  5593. result = Array(length);
  5594. while (++index < length) {
  5595. var array = arrays[index],
  5596. othIndex = -1;
  5597. while (++othIndex < length) {
  5598. if (othIndex != index) {
  5599. result[index] = baseDifference(result[index] || array, arrays[othIndex], iteratee, comparator);
  5600. }
  5601. }
  5602. }
  5603. return baseUniq(baseFlatten(result, 1), iteratee, comparator);
  5604. }
  5605. /**
  5606. * This base implementation of `_.zipObject` which assigns values using `assignFunc`.
  5607. *
  5608. * @private
  5609. * @param {Array} props The property identifiers.
  5610. * @param {Array} values The property values.
  5611. * @param {Function} assignFunc The function to assign values.
  5612. * @returns {Object} Returns the new object.
  5613. */
  5614. function baseZipObject(props, values, assignFunc) {
  5615. var index = -1,
  5616. length = props.length,
  5617. valsLength = values.length,
  5618. result = {};
  5619. while (++index < length) {
  5620. var value = index < valsLength ? values[index] : undefined;
  5621. assignFunc(result, props[index], value);
  5622. }
  5623. return result;
  5624. }
  5625. /**
  5626. * Casts `value` to an empty array if it's not an array like object.
  5627. *
  5628. * @private
  5629. * @param {*} value The value to inspect.
  5630. * @returns {Array|Object} Returns the cast array-like object.
  5631. */
  5632. function castArrayLikeObject(value) {
  5633. return isArrayLikeObject(value) ? value : [];
  5634. }
  5635. /**
  5636. * Casts `value` to `identity` if it's not a function.
  5637. *
  5638. * @private
  5639. * @param {*} value The value to inspect.
  5640. * @returns {Function} Returns cast function.
  5641. */
  5642. function castFunction(value) {
  5643. return typeof value == 'function' ? value : identity;
  5644. }
  5645. /**
  5646. * Casts `value` to a path array if it's not one.
  5647. *
  5648. * @private
  5649. * @param {*} value The value to inspect.
  5650. * @param {Object} [object] The object to query keys on.
  5651. * @returns {Array} Returns the cast property path array.
  5652. */
  5653. function castPath(value, object) {
  5654. if (isArray(value)) {
  5655. return value;
  5656. }
  5657. return isKey(value, object) ? [value] : stringToPath(toString(value));
  5658. }
  5659. /**
  5660. * A `baseRest` alias which can be replaced with `identity` by module
  5661. * replacement plugins.
  5662. *
  5663. * @private
  5664. * @type {Function}
  5665. * @param {Function} func The function to apply a rest parameter to.
  5666. * @returns {Function} Returns the new function.
  5667. */
  5668. var castRest = baseRest;
  5669. /**
  5670. * Casts `array` to a slice if it's needed.
  5671. *
  5672. * @private
  5673. * @param {Array} array The array to inspect.
  5674. * @param {number} start The start position.
  5675. * @param {number} [end=array.length] The end position.
  5676. * @returns {Array} Returns the cast slice.
  5677. */
  5678. function castSlice(array, start, end) {
  5679. var length = array.length;
  5680. end = end === undefined ? length : end;
  5681. return (!start && end >= length) ? array : baseSlice(array, start, end);
  5682. }
  5683. /**
  5684. * A simple wrapper around the global [`clearTimeout`](https://mdn.io/clearTimeout).
  5685. *
  5686. * @private
  5687. * @param {number|Object} id The timer id or timeout object of the timer to clear.
  5688. */
  5689. var clearTimeout = ctxClearTimeout || function(id) {
  5690. return root.clearTimeout(id);
  5691. };
  5692. /**
  5693. * Creates a clone of `buffer`.
  5694. *
  5695. * @private
  5696. * @param {Buffer} buffer The buffer to clone.
  5697. * @param {boolean} [isDeep] Specify a deep clone.
  5698. * @returns {Buffer} Returns the cloned buffer.
  5699. */
  5700. function cloneBuffer(buffer, isDeep) {
  5701. if (isDeep) {
  5702. return buffer.slice();
  5703. }
  5704. var length = buffer.length,
  5705. result = allocUnsafe ? allocUnsafe(length) : new buffer.constructor(length);
  5706. buffer.copy(result);
  5707. return result;
  5708. }
  5709. /**
  5710. * Creates a clone of `arrayBuffer`.
  5711. *
  5712. * @private
  5713. * @param {ArrayBuffer} arrayBuffer The array buffer to clone.
  5714. * @returns {ArrayBuffer} Returns the cloned array buffer.
  5715. */
  5716. function cloneArrayBuffer(arrayBuffer) {
  5717. var result = new arrayBuffer.constructor(arrayBuffer.byteLength);
  5718. new Uint8Array(result).set(new Uint8Array(arrayBuffer));
  5719. return result;
  5720. }
  5721. /**
  5722. * Creates a clone of `dataView`.
  5723. *
  5724. * @private
  5725. * @param {Object} dataView The data view to clone.
  5726. * @param {boolean} [isDeep] Specify a deep clone.
  5727. * @returns {Object} Returns the cloned data view.
  5728. */
  5729. function cloneDataView(dataView, isDeep) {
  5730. var buffer = isDeep ? cloneArrayBuffer(dataView.buffer) : dataView.buffer;
  5731. return new dataView.constructor(buffer, dataView.byteOffset, dataView.byteLength);
  5732. }
  5733. /**
  5734. * Creates a clone of `regexp`.
  5735. *
  5736. * @private
  5737. * @param {Object} regexp The regexp to clone.
  5738. * @returns {Object} Returns the cloned regexp.
  5739. */
  5740. function cloneRegExp(regexp) {
  5741. var result = new regexp.constructor(regexp.source, reFlags.exec(regexp));
  5742. result.lastIndex = regexp.lastIndex;
  5743. return result;
  5744. }
  5745. /**
  5746. * Creates a clone of the `symbol` object.
  5747. *
  5748. * @private
  5749. * @param {Object} symbol The symbol object to clone.
  5750. * @returns {Object} Returns the cloned symbol object.
  5751. */
  5752. function cloneSymbol(symbol) {
  5753. return symbolValueOf ? Object(symbolValueOf.call(symbol)) : {};
  5754. }
  5755. /**
  5756. * Creates a clone of `typedArray`.
  5757. *
  5758. * @private
  5759. * @param {Object} typedArray The typed array to clone.
  5760. * @param {boolean} [isDeep] Specify a deep clone.
  5761. * @returns {Object} Returns the cloned typed array.
  5762. */
  5763. function cloneTypedArray(typedArray, isDeep) {
  5764. var buffer = isDeep ? cloneArrayBuffer(typedArray.buffer) : typedArray.buffer;
  5765. return new typedArray.constructor(buffer, typedArray.byteOffset, typedArray.length);
  5766. }
  5767. /**
  5768. * Compares values to sort them in ascending order.
  5769. *
  5770. * @private
  5771. * @param {*} value The value to compare.
  5772. * @param {*} other The other value to compare.
  5773. * @returns {number} Returns the sort order indicator for `value`.
  5774. */
  5775. function compareAscending(value, other) {
  5776. if (value !== other) {
  5777. var valIsDefined = value !== undefined,
  5778. valIsNull = value === null,
  5779. valIsReflexive = value === value,
  5780. valIsSymbol = isSymbol(value);
  5781. var othIsDefined = other !== undefined,
  5782. othIsNull = other === null,
  5783. othIsReflexive = other === other,
  5784. othIsSymbol = isSymbol(other);
  5785. if ((!othIsNull && !othIsSymbol && !valIsSymbol && value > other) ||
  5786. (valIsSymbol && othIsDefined && othIsReflexive && !othIsNull && !othIsSymbol) ||
  5787. (valIsNull && othIsDefined && othIsReflexive) ||
  5788. (!valIsDefined && othIsReflexive) ||
  5789. !valIsReflexive) {
  5790. return 1;
  5791. }
  5792. if ((!valIsNull && !valIsSymbol && !othIsSymbol && value < other) ||
  5793. (othIsSymbol && valIsDefined && valIsReflexive && !valIsNull && !valIsSymbol) ||
  5794. (othIsNull && valIsDefined && valIsReflexive) ||
  5795. (!othIsDefined && valIsReflexive) ||
  5796. !othIsReflexive) {
  5797. return -1;
  5798. }
  5799. }
  5800. return 0;
  5801. }
  5802. /**
  5803. * Used by `_.orderBy` to compare multiple properties of a value to another
  5804. * and stable sort them.
  5805. *
  5806. * If `orders` is unspecified, all values are sorted in ascending order. Otherwise,
  5807. * specify an order of "desc" for descending or "asc" for ascending sort order
  5808. * of corresponding values.
  5809. *
  5810. * @private
  5811. * @param {Object} object The object to compare.
  5812. * @param {Object} other The other object to compare.
  5813. * @param {boolean[]|string[]} orders The order to sort by for each property.
  5814. * @returns {number} Returns the sort order indicator for `object`.
  5815. */
  5816. function compareMultiple(object, other, orders) {
  5817. var index = -1,
  5818. objCriteria = object.criteria,
  5819. othCriteria = other.criteria,
  5820. length = objCriteria.length,
  5821. ordersLength = orders.length;
  5822. while (++index < length) {
  5823. var result = compareAscending(objCriteria[index], othCriteria[index]);
  5824. if (result) {
  5825. if (index >= ordersLength) {
  5826. return result;
  5827. }
  5828. var order = orders[index];
  5829. return result * (order == 'desc' ? -1 : 1);
  5830. }
  5831. }
  5832. // Fixes an `Array#sort` bug in the JS engine embedded in Adobe applications
  5833. // that causes it, under certain circumstances, to provide the same value for
  5834. // `object` and `other`. See https://github.com/jashkenas/underscore/pull/1247
  5835. // for more details.
  5836. //
  5837. // This also ensures a stable sort in V8 and other engines.
  5838. // See https://bugs.chromium.org/p/v8/issues/detail?id=90 for more details.
  5839. return object.index - other.index;
  5840. }
  5841. /**
  5842. * Creates an array that is the composition of partially applied arguments,
  5843. * placeholders, and provided arguments into a single array of arguments.
  5844. *
  5845. * @private
  5846. * @param {Array} args The provided arguments.
  5847. * @param {Array} partials The arguments to prepend to those provided.
  5848. * @param {Array} holders The `partials` placeholder indexes.
  5849. * @params {boolean} [isCurried] Specify composing for a curried function.
  5850. * @returns {Array} Returns the new array of composed arguments.
  5851. */
  5852. function composeArgs(args, partials, holders, isCurried) {
  5853. var argsIndex = -1,
  5854. argsLength = args.length,
  5855. holdersLength = holders.length,
  5856. leftIndex = -1,
  5857. leftLength = partials.length,
  5858. rangeLength = nativeMax(argsLength - holdersLength, 0),
  5859. result = Array(leftLength + rangeLength),
  5860. isUncurried = !isCurried;
  5861. while (++leftIndex < leftLength) {
  5862. result[leftIndex] = partials[leftIndex];
  5863. }
  5864. while (++argsIndex < holdersLength) {
  5865. if (isUncurried || argsIndex < argsLength) {
  5866. result[holders[argsIndex]] = args[argsIndex];
  5867. }
  5868. }
  5869. while (rangeLength--) {
  5870. result[leftIndex++] = args[argsIndex++];
  5871. }
  5872. return result;
  5873. }
  5874. /**
  5875. * This function is like `composeArgs` except that the arguments composition
  5876. * is tailored for `_.partialRight`.
  5877. *
  5878. * @private
  5879. * @param {Array} args The provided arguments.
  5880. * @param {Array} partials The arguments to append to those provided.
  5881. * @param {Array} holders The `partials` placeholder indexes.
  5882. * @params {boolean} [isCurried] Specify composing for a curried function.
  5883. * @returns {Array} Returns the new array of composed arguments.
  5884. */
  5885. function composeArgsRight(args, partials, holders, isCurried) {
  5886. var argsIndex = -1,
  5887. argsLength = args.length,
  5888. holdersIndex = -1,
  5889. holdersLength = holders.length,
  5890. rightIndex = -1,
  5891. rightLength = partials.length,
  5892. rangeLength = nativeMax(argsLength - holdersLength, 0),
  5893. result = Array(rangeLength + rightLength),
  5894. isUncurried = !isCurried;
  5895. while (++argsIndex < rangeLength) {
  5896. result[argsIndex] = args[argsIndex];
  5897. }
  5898. var offset = argsIndex;
  5899. while (++rightIndex < rightLength) {
  5900. result[offset + rightIndex] = partials[rightIndex];
  5901. }
  5902. while (++holdersIndex < holdersLength) {
  5903. if (isUncurried || argsIndex < argsLength) {
  5904. result[offset + holders[holdersIndex]] = args[argsIndex++];
  5905. }
  5906. }
  5907. return result;
  5908. }
  5909. /**
  5910. * Copies the values of `source` to `array`.
  5911. *
  5912. * @private
  5913. * @param {Array} source The array to copy values from.
  5914. * @param {Array} [array=[]] The array to copy values to.
  5915. * @returns {Array} Returns `array`.
  5916. */
  5917. function copyArray(source, array) {
  5918. var index = -1,
  5919. length = source.length;
  5920. array || (array = Array(length));
  5921. while (++index < length) {
  5922. array[index] = source[index];
  5923. }
  5924. return array;
  5925. }
  5926. /**
  5927. * Copies properties of `source` to `object`.
  5928. *
  5929. * @private
  5930. * @param {Object} source The object to copy properties from.
  5931. * @param {Array} props The property identifiers to copy.
  5932. * @param {Object} [object={}] The object to copy properties to.
  5933. * @param {Function} [customizer] The function to customize copied values.
  5934. * @returns {Object} Returns `object`.
  5935. */
  5936. function copyObject(source, props, object, customizer) {
  5937. var isNew = !object;
  5938. object || (object = {});
  5939. var index = -1,
  5940. length = props.length;
  5941. while (++index < length) {
  5942. var key = props[index];
  5943. var newValue = customizer
  5944. ? customizer(object[key], source[key], key, object, source)
  5945. : undefined;
  5946. if (newValue === undefined) {
  5947. newValue = source[key];
  5948. }
  5949. if (isNew) {
  5950. baseAssignValue(object, key, newValue);
  5951. } else {
  5952. assignValue(object, key, newValue);
  5953. }
  5954. }
  5955. return object;
  5956. }
  5957. /**
  5958. * Copies own symbols of `source` to `object`.
  5959. *
  5960. * @private
  5961. * @param {Object} source The object to copy symbols from.
  5962. * @param {Object} [object={}] The object to copy symbols to.
  5963. * @returns {Object} Returns `object`.
  5964. */
  5965. function copySymbols(source, object) {
  5966. return copyObject(source, getSymbols(source), object);
  5967. }
  5968. /**
  5969. * Copies own and inherited symbols of `source` to `object`.
  5970. *
  5971. * @private
  5972. * @param {Object} source The object to copy symbols from.
  5973. * @param {Object} [object={}] The object to copy symbols to.
  5974. * @returns {Object} Returns `object`.
  5975. */
  5976. function copySymbolsIn(source, object) {
  5977. return copyObject(source, getSymbolsIn(source), object);
  5978. }
  5979. /**
  5980. * Creates a function like `_.groupBy`.
  5981. *
  5982. * @private
  5983. * @param {Function} setter The function to set accumulator values.
  5984. * @param {Function} [initializer] The accumulator object initializer.
  5985. * @returns {Function} Returns the new aggregator function.
  5986. */
  5987. function createAggregator(setter, initializer) {
  5988. return function(collection, iteratee) {
  5989. var func = isArray(collection) ? arrayAggregator : baseAggregator,
  5990. accumulator = initializer ? initializer() : {};
  5991. return func(collection, setter, getIteratee(iteratee, 2), accumulator);
  5992. };
  5993. }
  5994. /**
  5995. * Creates a function like `_.assign`.
  5996. *
  5997. * @private
  5998. * @param {Function} assigner The function to assign values.
  5999. * @returns {Function} Returns the new assigner function.
  6000. */
  6001. function createAssigner(assigner) {
  6002. return baseRest(function(object, sources) {
  6003. var index = -1,
  6004. length = sources.length,
  6005. customizer = length > 1 ? sources[length - 1] : undefined,
  6006. guard = length > 2 ? sources[2] : undefined;
  6007. customizer = (assigner.length > 3 && typeof customizer == 'function')
  6008. ? (length--, customizer)
  6009. : undefined;
  6010. if (guard && isIterateeCall(sources[0], sources[1], guard)) {
  6011. customizer = length < 3 ? undefined : customizer;
  6012. length = 1;
  6013. }
  6014. object = Object(object);
  6015. while (++index < length) {
  6016. var source = sources[index];
  6017. if (source) {
  6018. assigner(object, source, index, customizer);
  6019. }
  6020. }
  6021. return object;
  6022. });
  6023. }
  6024. /**
  6025. * Creates a `baseEach` or `baseEachRight` function.
  6026. *
  6027. * @private
  6028. * @param {Function} eachFunc The function to iterate over a collection.
  6029. * @param {boolean} [fromRight] Specify iterating from right to left.
  6030. * @returns {Function} Returns the new base function.
  6031. */
  6032. function createBaseEach(eachFunc, fromRight) {
  6033. return function(collection, iteratee) {
  6034. if (collection == null) {
  6035. return collection;
  6036. }
  6037. if (!isArrayLike(collection)) {
  6038. return eachFunc(collection, iteratee);
  6039. }
  6040. var length = collection.length,
  6041. index = fromRight ? length : -1,
  6042. iterable = Object(collection);
  6043. while ((fromRight ? index-- : ++index < length)) {
  6044. if (iteratee(iterable[index], index, iterable) === false) {
  6045. break;
  6046. }
  6047. }
  6048. return collection;
  6049. };
  6050. }
  6051. /**
  6052. * Creates a base function for methods like `_.forIn` and `_.forOwn`.
  6053. *
  6054. * @private
  6055. * @param {boolean} [fromRight] Specify iterating from right to left.
  6056. * @returns {Function} Returns the new base function.
  6057. */
  6058. function createBaseFor(fromRight) {
  6059. return function(object, iteratee, keysFunc) {
  6060. var index = -1,
  6061. iterable = Object(object),
  6062. props = keysFunc(object),
  6063. length = props.length;
  6064. while (length--) {
  6065. var key = props[fromRight ? length : ++index];
  6066. if (iteratee(iterable[key], key, iterable) === false) {
  6067. break;
  6068. }
  6069. }
  6070. return object;
  6071. };
  6072. }
  6073. /**
  6074. * Creates a function that wraps `func` to invoke it with the optional `this`
  6075. * binding of `thisArg`.
  6076. *
  6077. * @private
  6078. * @param {Function} func The function to wrap.
  6079. * @param {number} bitmask The bitmask flags. See `createWrap` for more details.
  6080. * @param {*} [thisArg] The `this` binding of `func`.
  6081. * @returns {Function} Returns the new wrapped function.
  6082. */
  6083. function createBind(func, bitmask, thisArg) {
  6084. var isBind = bitmask & WRAP_BIND_FLAG,
  6085. Ctor = createCtor(func);
  6086. function wrapper() {
  6087. var fn = (this && this !== root && this instanceof wrapper) ? Ctor : func;
  6088. return fn.apply(isBind ? thisArg : this, arguments);
  6089. }
  6090. return wrapper;
  6091. }
  6092. /**
  6093. * Creates a function like `_.lowerFirst`.
  6094. *
  6095. * @private
  6096. * @param {string} methodName The name of the `String` case method to use.
  6097. * @returns {Function} Returns the new case function.
  6098. */
  6099. function createCaseFirst(methodName) {
  6100. return function(string) {
  6101. string = toString(string);
  6102. var strSymbols = hasUnicode(string)
  6103. ? stringToArray(string)
  6104. : undefined;
  6105. var chr = strSymbols
  6106. ? strSymbols[0]
  6107. : string.charAt(0);
  6108. var trailing = strSymbols
  6109. ? castSlice(strSymbols, 1).join('')
  6110. : string.slice(1);
  6111. return chr[methodName]() + trailing;
  6112. };
  6113. }
  6114. /**
  6115. * Creates a function like `_.camelCase`.
  6116. *
  6117. * @private
  6118. * @param {Function} callback The function to combine each word.
  6119. * @returns {Function} Returns the new compounder function.
  6120. */
  6121. function createCompounder(callback) {
  6122. return function(string) {
  6123. return arrayReduce(words(deburr(string).replace(reApos, '')), callback, '');
  6124. };
  6125. }
  6126. /**
  6127. * Creates a function that produces an instance of `Ctor` regardless of
  6128. * whether it was invoked as part of a `new` expression or by `call` or `apply`.
  6129. *
  6130. * @private
  6131. * @param {Function} Ctor The constructor to wrap.
  6132. * @returns {Function} Returns the new wrapped function.
  6133. */
  6134. function createCtor(Ctor) {
  6135. return function() {
  6136. // Use a `switch` statement to work with class constructors. See
  6137. // http://ecma-international.org/ecma-262/7.0/#sec-ecmascript-function-objects-call-thisargument-argumentslist
  6138. // for more details.
  6139. var args = arguments;
  6140. switch (args.length) {
  6141. case 0: return new Ctor;
  6142. case 1: return new Ctor(args[0]);
  6143. case 2: return new Ctor(args[0], args[1]);
  6144. case 3: return new Ctor(args[0], args[1], args[2]);
  6145. case 4: return new Ctor(args[0], args[1], args[2], args[3]);
  6146. case 5: return new Ctor(args[0], args[1], args[2], args[3], args[4]);
  6147. case 6: return new Ctor(args[0], args[1], args[2], args[3], args[4], args[5]);
  6148. case 7: return new Ctor(args[0], args[1], args[2], args[3], args[4], args[5], args[6]);
  6149. }
  6150. var thisBinding = baseCreate(Ctor.prototype),
  6151. result = Ctor.apply(thisBinding, args);
  6152. // Mimic the constructor's `return` behavior.
  6153. // See https://es5.github.io/#x13.2.2 for more details.
  6154. return isObject(result) ? result : thisBinding;
  6155. };
  6156. }
  6157. /**
  6158. * Creates a function that wraps `func` to enable currying.
  6159. *
  6160. * @private
  6161. * @param {Function} func The function to wrap.
  6162. * @param {number} bitmask The bitmask flags. See `createWrap` for more details.
  6163. * @param {number} arity The arity of `func`.
  6164. * @returns {Function} Returns the new wrapped function.
  6165. */
  6166. function createCurry(func, bitmask, arity) {
  6167. var Ctor = createCtor(func);
  6168. function wrapper() {
  6169. var length = arguments.length,
  6170. args = Array(length),
  6171. index = length,
  6172. placeholder = getHolder(wrapper);
  6173. while (index--) {
  6174. args[index] = arguments[index];
  6175. }
  6176. var holders = (length < 3 && args[0] !== placeholder && args[length - 1] !== placeholder)
  6177. ? []
  6178. : replaceHolders(args, placeholder);
  6179. length -= holders.length;
  6180. if (length < arity) {
  6181. return createRecurry(
  6182. func, bitmask, createHybrid, wrapper.placeholder, undefined,
  6183. args, holders, undefined, undefined, arity - length);
  6184. }
  6185. var fn = (this && this !== root && this instanceof wrapper) ? Ctor : func;
  6186. return apply(fn, this, args);
  6187. }
  6188. return wrapper;
  6189. }
  6190. /**
  6191. * Creates a `_.find` or `_.findLast` function.
  6192. *
  6193. * @private
  6194. * @param {Function} findIndexFunc The function to find the collection index.
  6195. * @returns {Function} Returns the new find function.
  6196. */
  6197. function createFind(findIndexFunc) {
  6198. return function(collection, predicate, fromIndex) {
  6199. var iterable = Object(collection);
  6200. if (!isArrayLike(collection)) {
  6201. var iteratee = getIteratee(predicate, 3);
  6202. collection = keys(collection);
  6203. predicate = function(key) { return iteratee(iterable[key], key, iterable); };
  6204. }
  6205. var index = findIndexFunc(collection, predicate, fromIndex);
  6206. return index > -1 ? iterable[iteratee ? collection[index] : index] : undefined;
  6207. };
  6208. }
  6209. /**
  6210. * Creates a `_.flow` or `_.flowRight` function.
  6211. *
  6212. * @private
  6213. * @param {boolean} [fromRight] Specify iterating from right to left.
  6214. * @returns {Function} Returns the new flow function.
  6215. */
  6216. function createFlow(fromRight) {
  6217. return flatRest(function(funcs) {
  6218. var length = funcs.length,
  6219. index = length,
  6220. prereq = LodashWrapper.prototype.thru;
  6221. if (fromRight) {
  6222. funcs.reverse();
  6223. }
  6224. while (index--) {
  6225. var func = funcs[index];
  6226. if (typeof func != 'function') {
  6227. throw new TypeError(FUNC_ERROR_TEXT);
  6228. }
  6229. if (prereq && !wrapper && getFuncName(func) == 'wrapper') {
  6230. var wrapper = new LodashWrapper([], true);
  6231. }
  6232. }
  6233. index = wrapper ? index : length;
  6234. while (++index < length) {
  6235. func = funcs[index];
  6236. var funcName = getFuncName(func),
  6237. data = funcName == 'wrapper' ? getData(func) : undefined;
  6238. if (data && isLaziable(data[0]) &&
  6239. data[1] == (WRAP_ARY_FLAG | WRAP_CURRY_FLAG | WRAP_PARTIAL_FLAG | WRAP_REARG_FLAG) &&
  6240. !data[4].length && data[9] == 1
  6241. ) {
  6242. wrapper = wrapper[getFuncName(data[0])].apply(wrapper, data[3]);
  6243. } else {
  6244. wrapper = (func.length == 1 && isLaziable(func))
  6245. ? wrapper[funcName]()
  6246. : wrapper.thru(func);
  6247. }
  6248. }
  6249. return function() {
  6250. var args = arguments,
  6251. value = args[0];
  6252. if (wrapper && args.length == 1 && isArray(value)) {
  6253. return wrapper.plant(value).value();
  6254. }
  6255. var index = 0,
  6256. result = length ? funcs[index].apply(this, args) : value;
  6257. while (++index < length) {
  6258. result = funcs[index].call(this, result);
  6259. }
  6260. return result;
  6261. };
  6262. });
  6263. }
  6264. /**
  6265. * Creates a function that wraps `func` to invoke it with optional `this`
  6266. * binding of `thisArg`, partial application, and currying.
  6267. *
  6268. * @private
  6269. * @param {Function|string} func The function or method name to wrap.
  6270. * @param {number} bitmask The bitmask flags. See `createWrap` for more details.
  6271. * @param {*} [thisArg] The `this` binding of `func`.
  6272. * @param {Array} [partials] The arguments to prepend to those provided to
  6273. * the new function.
  6274. * @param {Array} [holders] The `partials` placeholder indexes.
  6275. * @param {Array} [partialsRight] The arguments to append to those provided
  6276. * to the new function.
  6277. * @param {Array} [holdersRight] The `partialsRight` placeholder indexes.
  6278. * @param {Array} [argPos] The argument positions of the new function.
  6279. * @param {number} [ary] The arity cap of `func`.
  6280. * @param {number} [arity] The arity of `func`.
  6281. * @returns {Function} Returns the new wrapped function.
  6282. */
  6283. function createHybrid(func, bitmask, thisArg, partials, holders, partialsRight, holdersRight, argPos, ary, arity) {
  6284. var isAry = bitmask & WRAP_ARY_FLAG,
  6285. isBind = bitmask & WRAP_BIND_FLAG,
  6286. isBindKey = bitmask & WRAP_BIND_KEY_FLAG,
  6287. isCurried = bitmask & (WRAP_CURRY_FLAG | WRAP_CURRY_RIGHT_FLAG),
  6288. isFlip = bitmask & WRAP_FLIP_FLAG,
  6289. Ctor = isBindKey ? undefined : createCtor(func);
  6290. function wrapper() {
  6291. var length = arguments.length,
  6292. args = Array(length),
  6293. index = length;
  6294. while (index--) {
  6295. args[index] = arguments[index];
  6296. }
  6297. if (isCurried) {
  6298. var placeholder = getHolder(wrapper),
  6299. holdersCount = countHolders(args, placeholder);
  6300. }
  6301. if (partials) {
  6302. args = composeArgs(args, partials, holders, isCurried);
  6303. }
  6304. if (partialsRight) {
  6305. args = composeArgsRight(args, partialsRight, holdersRight, isCurried);
  6306. }
  6307. length -= holdersCount;
  6308. if (isCurried && length < arity) {
  6309. var newHolders = replaceHolders(args, placeholder);
  6310. return createRecurry(
  6311. func, bitmask, createHybrid, wrapper.placeholder, thisArg,
  6312. args, newHolders, argPos, ary, arity - length
  6313. );
  6314. }
  6315. var thisBinding = isBind ? thisArg : this,
  6316. fn = isBindKey ? thisBinding[func] : func;
  6317. length = args.length;
  6318. if (argPos) {
  6319. args = reorder(args, argPos);
  6320. } else if (isFlip && length > 1) {
  6321. args.reverse();
  6322. }
  6323. if (isAry && ary < length) {
  6324. args.length = ary;
  6325. }
  6326. if (this && this !== root && this instanceof wrapper) {
  6327. fn = Ctor || createCtor(fn);
  6328. }
  6329. return fn.apply(thisBinding, args);
  6330. }
  6331. return wrapper;
  6332. }
  6333. /**
  6334. * Creates a function like `_.invertBy`.
  6335. *
  6336. * @private
  6337. * @param {Function} setter The function to set accumulator values.
  6338. * @param {Function} toIteratee The function to resolve iteratees.
  6339. * @returns {Function} Returns the new inverter function.
  6340. */
  6341. function createInverter(setter, toIteratee) {
  6342. return function(object, iteratee) {
  6343. return baseInverter(object, setter, toIteratee(iteratee), {});
  6344. };
  6345. }
  6346. /**
  6347. * Creates a function that performs a mathematical operation on two values.
  6348. *
  6349. * @private
  6350. * @param {Function} operator The function to perform the operation.
  6351. * @param {number} [defaultValue] The value used for `undefined` arguments.
  6352. * @returns {Function} Returns the new mathematical operation function.
  6353. */
  6354. function createMathOperation(operator, defaultValue) {
  6355. return function(value, other) {
  6356. var result;
  6357. if (value === undefined && other === undefined) {
  6358. return defaultValue;
  6359. }
  6360. if (value !== undefined) {
  6361. result = value;
  6362. }
  6363. if (other !== undefined) {
  6364. if (result === undefined) {
  6365. return other;
  6366. }
  6367. if (typeof value == 'string' || typeof other == 'string') {
  6368. value = baseToString(value);
  6369. other = baseToString(other);
  6370. } else {
  6371. value = baseToNumber(value);
  6372. other = baseToNumber(other);
  6373. }
  6374. result = operator(value, other);
  6375. }
  6376. return result;
  6377. };
  6378. }
  6379. /**
  6380. * Creates a function like `_.over`.
  6381. *
  6382. * @private
  6383. * @param {Function} arrayFunc The function to iterate over iteratees.
  6384. * @returns {Function} Returns the new over function.
  6385. */
  6386. function createOver(arrayFunc) {
  6387. return flatRest(function(iteratees) {
  6388. iteratees = arrayMap(iteratees, baseUnary(getIteratee()));
  6389. return baseRest(function(args) {
  6390. var thisArg = this;
  6391. return arrayFunc(iteratees, function(iteratee) {
  6392. return apply(iteratee, thisArg, args);
  6393. });
  6394. });
  6395. });
  6396. }
  6397. /**
  6398. * Creates the padding for `string` based on `length`. The `chars` string
  6399. * is truncated if the number of characters exceeds `length`.
  6400. *
  6401. * @private
  6402. * @param {number} length The padding length.
  6403. * @param {string} [chars=' '] The string used as padding.
  6404. * @returns {string} Returns the padding for `string`.
  6405. */
  6406. function createPadding(length, chars) {
  6407. chars = chars === undefined ? ' ' : baseToString(chars);
  6408. var charsLength = chars.length;
  6409. if (charsLength < 2) {
  6410. return charsLength ? baseRepeat(chars, length) : chars;
  6411. }
  6412. var result = baseRepeat(chars, nativeCeil(length / stringSize(chars)));
  6413. return hasUnicode(chars)
  6414. ? castSlice(stringToArray(result), 0, length).join('')
  6415. : result.slice(0, length);
  6416. }
  6417. /**
  6418. * Creates a function that wraps `func` to invoke it with the `this` binding
  6419. * of `thisArg` and `partials` prepended to the arguments it receives.
  6420. *
  6421. * @private
  6422. * @param {Function} func The function to wrap.
  6423. * @param {number} bitmask The bitmask flags. See `createWrap` for more details.
  6424. * @param {*} thisArg The `this` binding of `func`.
  6425. * @param {Array} partials The arguments to prepend to those provided to
  6426. * the new function.
  6427. * @returns {Function} Returns the new wrapped function.
  6428. */
  6429. function createPartial(func, bitmask, thisArg, partials) {
  6430. var isBind = bitmask & WRAP_BIND_FLAG,
  6431. Ctor = createCtor(func);
  6432. function wrapper() {
  6433. var argsIndex = -1,
  6434. argsLength = arguments.length,
  6435. leftIndex = -1,
  6436. leftLength = partials.length,
  6437. args = Array(leftLength + argsLength),
  6438. fn = (this && this !== root && this instanceof wrapper) ? Ctor : func;
  6439. while (++leftIndex < leftLength) {
  6440. args[leftIndex] = partials[leftIndex];
  6441. }
  6442. while (argsLength--) {
  6443. args[leftIndex++] = arguments[++argsIndex];
  6444. }
  6445. return apply(fn, isBind ? thisArg : this, args);
  6446. }
  6447. return wrapper;
  6448. }
  6449. /**
  6450. * Creates a `_.range` or `_.rangeRight` function.
  6451. *
  6452. * @private
  6453. * @param {boolean} [fromRight] Specify iterating from right to left.
  6454. * @returns {Function} Returns the new range function.
  6455. */
  6456. function createRange(fromRight) {
  6457. return function(start, end, step) {
  6458. if (step && typeof step != 'number' && isIterateeCall(start, end, step)) {
  6459. end = step = undefined;
  6460. }
  6461. // Ensure the sign of `-0` is preserved.
  6462. start = toFinite(start);
  6463. if (end === undefined) {
  6464. end = start;
  6465. start = 0;
  6466. } else {
  6467. end = toFinite(end);
  6468. }
  6469. step = step === undefined ? (start < end ? 1 : -1) : toFinite(step);
  6470. return baseRange(start, end, step, fromRight);
  6471. };
  6472. }
  6473. /**
  6474. * Creates a function that performs a relational operation on two values.
  6475. *
  6476. * @private
  6477. * @param {Function} operator The function to perform the operation.
  6478. * @returns {Function} Returns the new relational operation function.
  6479. */
  6480. function createRelationalOperation(operator) {
  6481. return function(value, other) {
  6482. if (!(typeof value == 'string' && typeof other == 'string')) {
  6483. value = toNumber(value);
  6484. other = toNumber(other);
  6485. }
  6486. return operator(value, other);
  6487. };
  6488. }
  6489. /**
  6490. * Creates a function that wraps `func` to continue currying.
  6491. *
  6492. * @private
  6493. * @param {Function} func The function to wrap.
  6494. * @param {number} bitmask The bitmask flags. See `createWrap` for more details.
  6495. * @param {Function} wrapFunc The function to create the `func` wrapper.
  6496. * @param {*} placeholder The placeholder value.
  6497. * @param {*} [thisArg] The `this` binding of `func`.
  6498. * @param {Array} [partials] The arguments to prepend to those provided to
  6499. * the new function.
  6500. * @param {Array} [holders] The `partials` placeholder indexes.
  6501. * @param {Array} [argPos] The argument positions of the new function.
  6502. * @param {number} [ary] The arity cap of `func`.
  6503. * @param {number} [arity] The arity of `func`.
  6504. * @returns {Function} Returns the new wrapped function.
  6505. */
  6506. function createRecurry(func, bitmask, wrapFunc, placeholder, thisArg, partials, holders, argPos, ary, arity) {
  6507. var isCurry = bitmask & WRAP_CURRY_FLAG,
  6508. newHolders = isCurry ? holders : undefined,
  6509. newHoldersRight = isCurry ? undefined : holders,
  6510. newPartials = isCurry ? partials : undefined,
  6511. newPartialsRight = isCurry ? undefined : partials;
  6512. bitmask |= (isCurry ? WRAP_PARTIAL_FLAG : WRAP_PARTIAL_RIGHT_FLAG);
  6513. bitmask &= ~(isCurry ? WRAP_PARTIAL_RIGHT_FLAG : WRAP_PARTIAL_FLAG);
  6514. if (!(bitmask & WRAP_CURRY_BOUND_FLAG)) {
  6515. bitmask &= ~(WRAP_BIND_FLAG | WRAP_BIND_KEY_FLAG);
  6516. }
  6517. var newData = [
  6518. func, bitmask, thisArg, newPartials, newHolders, newPartialsRight,
  6519. newHoldersRight, argPos, ary, arity
  6520. ];
  6521. var result = wrapFunc.apply(undefined, newData);
  6522. if (isLaziable(func)) {
  6523. setData(result, newData);
  6524. }
  6525. result.placeholder = placeholder;
  6526. return setWrapToString(result, func, bitmask);
  6527. }
  6528. /**
  6529. * Creates a function like `_.round`.
  6530. *
  6531. * @private
  6532. * @param {string} methodName The name of the `Math` method to use when rounding.
  6533. * @returns {Function} Returns the new round function.
  6534. */
  6535. function createRound(methodName) {
  6536. var func = Math[methodName];
  6537. return function(number, precision) {
  6538. number = toNumber(number);
  6539. precision = precision == null ? 0 : nativeMin(toInteger(precision), 292);
  6540. if (precision && nativeIsFinite(number)) {
  6541. // Shift with exponential notation to avoid floating-point issues.
  6542. // See [MDN](https://mdn.io/round#Examples) for more details.
  6543. var pair = (toString(number) + 'e').split('e'),
  6544. value = func(pair[0] + 'e' + (+pair[1] + precision));
  6545. pair = (toString(value) + 'e').split('e');
  6546. return +(pair[0] + 'e' + (+pair[1] - precision));
  6547. }
  6548. return func(number);
  6549. };
  6550. }
  6551. /**
  6552. * Creates a set object of `values`.
  6553. *
  6554. * @private
  6555. * @param {Array} values The values to add to the set.
  6556. * @returns {Object} Returns the new set.
  6557. */
  6558. var createSet = !(Set && (1 / setToArray(new Set([,-0]))[1]) == INFINITY) ? noop : function(values) {
  6559. return new Set(values);
  6560. };
  6561. /**
  6562. * Creates a `_.toPairs` or `_.toPairsIn` function.
  6563. *
  6564. * @private
  6565. * @param {Function} keysFunc The function to get the keys of a given object.
  6566. * @returns {Function} Returns the new pairs function.
  6567. */
  6568. function createToPairs(keysFunc) {
  6569. return function(object) {
  6570. var tag = getTag(object);
  6571. if (tag == mapTag) {
  6572. return mapToArray(object);
  6573. }
  6574. if (tag == setTag) {
  6575. return setToPairs(object);
  6576. }
  6577. return baseToPairs(object, keysFunc(object));
  6578. };
  6579. }
  6580. /**
  6581. * Creates a function that either curries or invokes `func` with optional
  6582. * `this` binding and partially applied arguments.
  6583. *
  6584. * @private
  6585. * @param {Function|string} func The function or method name to wrap.
  6586. * @param {number} bitmask The bitmask flags.
  6587. * 1 - `_.bind`
  6588. * 2 - `_.bindKey`
  6589. * 4 - `_.curry` or `_.curryRight` of a bound function
  6590. * 8 - `_.curry`
  6591. * 16 - `_.curryRight`
  6592. * 32 - `_.partial`
  6593. * 64 - `_.partialRight`
  6594. * 128 - `_.rearg`
  6595. * 256 - `_.ary`
  6596. * 512 - `_.flip`
  6597. * @param {*} [thisArg] The `this` binding of `func`.
  6598. * @param {Array} [partials] The arguments to be partially applied.
  6599. * @param {Array} [holders] The `partials` placeholder indexes.
  6600. * @param {Array} [argPos] The argument positions of the new function.
  6601. * @param {number} [ary] The arity cap of `func`.
  6602. * @param {number} [arity] The arity of `func`.
  6603. * @returns {Function} Returns the new wrapped function.
  6604. */
  6605. function createWrap(func, bitmask, thisArg, partials, holders, argPos, ary, arity) {
  6606. var isBindKey = bitmask & WRAP_BIND_KEY_FLAG;
  6607. if (!isBindKey && typeof func != 'function') {
  6608. throw new TypeError(FUNC_ERROR_TEXT);
  6609. }
  6610. var length = partials ? partials.length : 0;
  6611. if (!length) {
  6612. bitmask &= ~(WRAP_PARTIAL_FLAG | WRAP_PARTIAL_RIGHT_FLAG);
  6613. partials = holders = undefined;
  6614. }
  6615. ary = ary === undefined ? ary : nativeMax(toInteger(ary), 0);
  6616. arity = arity === undefined ? arity : toInteger(arity);
  6617. length -= holders ? holders.length : 0;
  6618. if (bitmask & WRAP_PARTIAL_RIGHT_FLAG) {
  6619. var partialsRight = partials,
  6620. holdersRight = holders;
  6621. partials = holders = undefined;
  6622. }
  6623. var data = isBindKey ? undefined : getData(func);
  6624. var newData = [
  6625. func, bitmask, thisArg, partials, holders, partialsRight, holdersRight,
  6626. argPos, ary, arity
  6627. ];
  6628. if (data) {
  6629. mergeData(newData, data);
  6630. }
  6631. func = newData[0];
  6632. bitmask = newData[1];
  6633. thisArg = newData[2];
  6634. partials = newData[3];
  6635. holders = newData[4];
  6636. arity = newData[9] = newData[9] === undefined
  6637. ? (isBindKey ? 0 : func.length)
  6638. : nativeMax(newData[9] - length, 0);
  6639. if (!arity && bitmask & (WRAP_CURRY_FLAG | WRAP_CURRY_RIGHT_FLAG)) {
  6640. bitmask &= ~(WRAP_CURRY_FLAG | WRAP_CURRY_RIGHT_FLAG);
  6641. }
  6642. if (!bitmask || bitmask == WRAP_BIND_FLAG) {
  6643. var result = createBind(func, bitmask, thisArg);
  6644. } else if (bitmask == WRAP_CURRY_FLAG || bitmask == WRAP_CURRY_RIGHT_FLAG) {
  6645. result = createCurry(func, bitmask, arity);
  6646. } else if ((bitmask == WRAP_PARTIAL_FLAG || bitmask == (WRAP_BIND_FLAG | WRAP_PARTIAL_FLAG)) && !holders.length) {
  6647. result = createPartial(func, bitmask, thisArg, partials);
  6648. } else {
  6649. result = createHybrid.apply(undefined, newData);
  6650. }
  6651. var setter = data ? baseSetData : setData;
  6652. return setWrapToString(setter(result, newData), func, bitmask);
  6653. }
  6654. /**
  6655. * Used by `_.defaults` to customize its `_.assignIn` use to assign properties
  6656. * of source objects to the destination object for all destination properties
  6657. * that resolve to `undefined`.
  6658. *
  6659. * @private
  6660. * @param {*} objValue The destination value.
  6661. * @param {*} srcValue The source value.
  6662. * @param {string} key The key of the property to assign.
  6663. * @param {Object} object The parent object of `objValue`.
  6664. * @returns {*} Returns the value to assign.
  6665. */
  6666. function customDefaultsAssignIn(objValue, srcValue, key, object) {
  6667. if (objValue === undefined ||
  6668. (eq(objValue, objectProto[key]) && !hasOwnProperty.call(object, key))) {
  6669. return srcValue;
  6670. }
  6671. return objValue;
  6672. }
  6673. /**
  6674. * Used by `_.defaultsDeep` to customize its `_.merge` use to merge source
  6675. * objects into destination objects that are passed thru.
  6676. *
  6677. * @private
  6678. * @param {*} objValue The destination value.
  6679. * @param {*} srcValue The source value.
  6680. * @param {string} key The key of the property to merge.
  6681. * @param {Object} object The parent object of `objValue`.
  6682. * @param {Object} source The parent object of `srcValue`.
  6683. * @param {Object} [stack] Tracks traversed source values and their merged
  6684. * counterparts.
  6685. * @returns {*} Returns the value to assign.
  6686. */
  6687. function customDefaultsMerge(objValue, srcValue, key, object, source, stack) {
  6688. if (isObject(objValue) && isObject(srcValue)) {
  6689. // Recursively merge objects and arrays (susceptible to call stack limits).
  6690. stack.set(srcValue, objValue);
  6691. baseMerge(objValue, srcValue, undefined, customDefaultsMerge, stack);
  6692. stack['delete'](srcValue);
  6693. }
  6694. return objValue;
  6695. }
  6696. /**
  6697. * Used by `_.omit` to customize its `_.cloneDeep` use to only clone plain
  6698. * objects.
  6699. *
  6700. * @private
  6701. * @param {*} value The value to inspect.
  6702. * @param {string} key The key of the property to inspect.
  6703. * @returns {*} Returns the uncloned value or `undefined` to defer cloning to `_.cloneDeep`.
  6704. */
  6705. function customOmitClone(value) {
  6706. return isPlainObject(value) ? undefined : value;
  6707. }
  6708. /**
  6709. * A specialized version of `baseIsEqualDeep` for arrays with support for
  6710. * partial deep comparisons.
  6711. *
  6712. * @private
  6713. * @param {Array} array The array to compare.
  6714. * @param {Array} other The other array to compare.
  6715. * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.
  6716. * @param {Function} customizer The function to customize comparisons.
  6717. * @param {Function} equalFunc The function to determine equivalents of values.
  6718. * @param {Object} stack Tracks traversed `array` and `other` objects.
  6719. * @returns {boolean} Returns `true` if the arrays are equivalent, else `false`.
  6720. */
  6721. function equalArrays(array, other, bitmask, customizer, equalFunc, stack) {
  6722. var isPartial = bitmask & COMPARE_PARTIAL_FLAG,
  6723. arrLength = array.length,
  6724. othLength = other.length;
  6725. if (arrLength != othLength && !(isPartial && othLength > arrLength)) {
  6726. return false;
  6727. }
  6728. // Check that cyclic values are equal.
  6729. var arrStacked = stack.get(array);
  6730. var othStacked = stack.get(other);
  6731. if (arrStacked && othStacked) {
  6732. return arrStacked == other && othStacked == array;
  6733. }
  6734. var index = -1,
  6735. result = true,
  6736. seen = (bitmask & COMPARE_UNORDERED_FLAG) ? new SetCache : undefined;
  6737. stack.set(array, other);
  6738. stack.set(other, array);
  6739. // Ignore non-index properties.
  6740. while (++index < arrLength) {
  6741. var arrValue = array[index],
  6742. othValue = other[index];
  6743. if (customizer) {
  6744. var compared = isPartial
  6745. ? customizer(othValue, arrValue, index, other, array, stack)
  6746. : customizer(arrValue, othValue, index, array, other, stack);
  6747. }
  6748. if (compared !== undefined) {
  6749. if (compared) {
  6750. continue;
  6751. }
  6752. result = false;
  6753. break;
  6754. }
  6755. // Recursively compare arrays (susceptible to call stack limits).
  6756. if (seen) {
  6757. if (!arraySome(other, function(othValue, othIndex) {
  6758. if (!cacheHas(seen, othIndex) &&
  6759. (arrValue === othValue || equalFunc(arrValue, othValue, bitmask, customizer, stack))) {
  6760. return seen.push(othIndex);
  6761. }
  6762. })) {
  6763. result = false;
  6764. break;
  6765. }
  6766. } else if (!(
  6767. arrValue === othValue ||
  6768. equalFunc(arrValue, othValue, bitmask, customizer, stack)
  6769. )) {
  6770. result = false;
  6771. break;
  6772. }
  6773. }
  6774. stack['delete'](array);
  6775. stack['delete'](other);
  6776. return result;
  6777. }
  6778. /**
  6779. * A specialized version of `baseIsEqualDeep` for comparing objects of
  6780. * the same `toStringTag`.
  6781. *
  6782. * **Note:** This function only supports comparing values with tags of
  6783. * `Boolean`, `Date`, `Error`, `Number`, `RegExp`, or `String`.
  6784. *
  6785. * @private
  6786. * @param {Object} object The object to compare.
  6787. * @param {Object} other The other object to compare.
  6788. * @param {string} tag The `toStringTag` of the objects to compare.
  6789. * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.
  6790. * @param {Function} customizer The function to customize comparisons.
  6791. * @param {Function} equalFunc The function to determine equivalents of values.
  6792. * @param {Object} stack Tracks traversed `object` and `other` objects.
  6793. * @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
  6794. */
  6795. function equalByTag(object, other, tag, bitmask, customizer, equalFunc, stack) {
  6796. switch (tag) {
  6797. case dataViewTag:
  6798. if ((object.byteLength != other.byteLength) ||
  6799. (object.byteOffset != other.byteOffset)) {
  6800. return false;
  6801. }
  6802. object = object.buffer;
  6803. other = other.buffer;
  6804. case arrayBufferTag:
  6805. if ((object.byteLength != other.byteLength) ||
  6806. !equalFunc(new Uint8Array(object), new Uint8Array(other))) {
  6807. return false;
  6808. }
  6809. return true;
  6810. case boolTag:
  6811. case dateTag:
  6812. case numberTag:
  6813. // Coerce booleans to `1` or `0` and dates to milliseconds.
  6814. // Invalid dates are coerced to `NaN`.
  6815. return eq(+object, +other);
  6816. case errorTag:
  6817. return object.name == other.name && object.message == other.message;
  6818. case regexpTag:
  6819. case stringTag:
  6820. // Coerce regexes to strings and treat strings, primitives and objects,
  6821. // as equal. See http://www.ecma-international.org/ecma-262/7.0/#sec-regexp.prototype.tostring
  6822. // for more details.
  6823. return object == (other + '');
  6824. case mapTag:
  6825. var convert = mapToArray;
  6826. case setTag:
  6827. var isPartial = bitmask & COMPARE_PARTIAL_FLAG;
  6828. convert || (convert = setToArray);
  6829. if (object.size != other.size && !isPartial) {
  6830. return false;
  6831. }
  6832. // Assume cyclic values are equal.
  6833. var stacked = stack.get(object);
  6834. if (stacked) {
  6835. return stacked == other;
  6836. }
  6837. bitmask |= COMPARE_UNORDERED_FLAG;
  6838. // Recursively compare objects (susceptible to call stack limits).
  6839. stack.set(object, other);
  6840. var result = equalArrays(convert(object), convert(other), bitmask, customizer, equalFunc, stack);
  6841. stack['delete'](object);
  6842. return result;
  6843. case symbolTag:
  6844. if (symbolValueOf) {
  6845. return symbolValueOf.call(object) == symbolValueOf.call(other);
  6846. }
  6847. }
  6848. return false;
  6849. }
  6850. /**
  6851. * A specialized version of `baseIsEqualDeep` for objects with support for
  6852. * partial deep comparisons.
  6853. *
  6854. * @private
  6855. * @param {Object} object The object to compare.
  6856. * @param {Object} other The other object to compare.
  6857. * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.
  6858. * @param {Function} customizer The function to customize comparisons.
  6859. * @param {Function} equalFunc The function to determine equivalents of values.
  6860. * @param {Object} stack Tracks traversed `object` and `other` objects.
  6861. * @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
  6862. */
  6863. function equalObjects(object, other, bitmask, customizer, equalFunc, stack) {
  6864. var isPartial = bitmask & COMPARE_PARTIAL_FLAG,
  6865. objProps = getAllKeys(object),
  6866. objLength = objProps.length,
  6867. othProps = getAllKeys(other),
  6868. othLength = othProps.length;
  6869. if (objLength != othLength && !isPartial) {
  6870. return false;
  6871. }
  6872. var index = objLength;
  6873. while (index--) {
  6874. var key = objProps[index];
  6875. if (!(isPartial ? key in other : hasOwnProperty.call(other, key))) {
  6876. return false;
  6877. }
  6878. }
  6879. // Check that cyclic values are equal.
  6880. var objStacked = stack.get(object);
  6881. var othStacked = stack.get(other);
  6882. if (objStacked && othStacked) {
  6883. return objStacked == other && othStacked == object;
  6884. }
  6885. var result = true;
  6886. stack.set(object, other);
  6887. stack.set(other, object);
  6888. var skipCtor = isPartial;
  6889. while (++index < objLength) {
  6890. key = objProps[index];
  6891. var objValue = object[key],
  6892. othValue = other[key];
  6893. if (customizer) {
  6894. var compared = isPartial
  6895. ? customizer(othValue, objValue, key, other, object, stack)
  6896. : customizer(objValue, othValue, key, object, other, stack);
  6897. }
  6898. // Recursively compare objects (susceptible to call stack limits).
  6899. if (!(compared === undefined
  6900. ? (objValue === othValue || equalFunc(objValue, othValue, bitmask, customizer, stack))
  6901. : compared
  6902. )) {
  6903. result = false;
  6904. break;
  6905. }
  6906. skipCtor || (skipCtor = key == 'constructor');
  6907. }
  6908. if (result && !skipCtor) {
  6909. var objCtor = object.constructor,
  6910. othCtor = other.constructor;
  6911. // Non `Object` object instances with different constructors are not equal.
  6912. if (objCtor != othCtor &&
  6913. ('constructor' in object && 'constructor' in other) &&
  6914. !(typeof objCtor == 'function' && objCtor instanceof objCtor &&
  6915. typeof othCtor == 'function' && othCtor instanceof othCtor)) {
  6916. result = false;
  6917. }
  6918. }
  6919. stack['delete'](object);
  6920. stack['delete'](other);
  6921. return result;
  6922. }
  6923. /**
  6924. * A specialized version of `baseRest` which flattens the rest array.
  6925. *
  6926. * @private
  6927. * @param {Function} func The function to apply a rest parameter to.
  6928. * @returns {Function} Returns the new function.
  6929. */
  6930. function flatRest(func) {
  6931. return setToString(overRest(func, undefined, flatten), func + '');
  6932. }
  6933. /**
  6934. * Creates an array of own enumerable property names and symbols of `object`.
  6935. *
  6936. * @private
  6937. * @param {Object} object The object to query.
  6938. * @returns {Array} Returns the array of property names and symbols.
  6939. */
  6940. function getAllKeys(object) {
  6941. return baseGetAllKeys(object, keys, getSymbols);
  6942. }
  6943. /**
  6944. * Creates an array of own and inherited enumerable property names and
  6945. * symbols of `object`.
  6946. *
  6947. * @private
  6948. * @param {Object} object The object to query.
  6949. * @returns {Array} Returns the array of property names and symbols.
  6950. */
  6951. function getAllKeysIn(object) {
  6952. return baseGetAllKeys(object, keysIn, getSymbolsIn);
  6953. }
  6954. /**
  6955. * Gets metadata for `func`.
  6956. *
  6957. * @private
  6958. * @param {Function} func The function to query.
  6959. * @returns {*} Returns the metadata for `func`.
  6960. */
  6961. var getData = !metaMap ? noop : function(func) {
  6962. return metaMap.get(func);
  6963. };
  6964. /**
  6965. * Gets the name of `func`.
  6966. *
  6967. * @private
  6968. * @param {Function} func The function to query.
  6969. * @returns {string} Returns the function name.
  6970. */
  6971. function getFuncName(func) {
  6972. var result = (func.name + ''),
  6973. array = realNames[result],
  6974. length = hasOwnProperty.call(realNames, result) ? array.length : 0;
  6975. while (length--) {
  6976. var data = array[length],
  6977. otherFunc = data.func;
  6978. if (otherFunc == null || otherFunc == func) {
  6979. return data.name;
  6980. }
  6981. }
  6982. return result;
  6983. }
  6984. /**
  6985. * Gets the argument placeholder value for `func`.
  6986. *
  6987. * @private
  6988. * @param {Function} func The function to inspect.
  6989. * @returns {*} Returns the placeholder value.
  6990. */
  6991. function getHolder(func) {
  6992. var object = hasOwnProperty.call(lodash, 'placeholder') ? lodash : func;
  6993. return object.placeholder;
  6994. }
  6995. /**
  6996. * Gets the appropriate "iteratee" function. If `_.iteratee` is customized,
  6997. * this function returns the custom method, otherwise it returns `baseIteratee`.
  6998. * If arguments are provided, the chosen function is invoked with them and
  6999. * its result is returned.
  7000. *
  7001. * @private
  7002. * @param {*} [value] The value to convert to an iteratee.
  7003. * @param {number} [arity] The arity of the created iteratee.
  7004. * @returns {Function} Returns the chosen function or its result.
  7005. */
  7006. function getIteratee() {
  7007. var result = lodash.iteratee || iteratee;
  7008. result = result === iteratee ? baseIteratee : result;
  7009. return arguments.length ? result(arguments[0], arguments[1]) : result;
  7010. }
  7011. /**
  7012. * Gets the data for `map`.
  7013. *
  7014. * @private
  7015. * @param {Object} map The map to query.
  7016. * @param {string} key The reference key.
  7017. * @returns {*} Returns the map data.
  7018. */
  7019. function getMapData(map, key) {
  7020. var data = map.__data__;
  7021. return isKeyable(key)
  7022. ? data[typeof key == 'string' ? 'string' : 'hash']
  7023. : data.map;
  7024. }
  7025. /**
  7026. * Gets the property names, values, and compare flags of `object`.
  7027. *
  7028. * @private
  7029. * @param {Object} object The object to query.
  7030. * @returns {Array} Returns the match data of `object`.
  7031. */
  7032. function getMatchData(object) {
  7033. var result = keys(object),
  7034. length = result.length;
  7035. while (length--) {
  7036. var key = result[length],
  7037. value = object[key];
  7038. result[length] = [key, value, isStrictComparable(value)];
  7039. }
  7040. return result;
  7041. }
  7042. /**
  7043. * Gets the native function at `key` of `object`.
  7044. *
  7045. * @private
  7046. * @param {Object} object The object to query.
  7047. * @param {string} key The key of the method to get.
  7048. * @returns {*} Returns the function if it's native, else `undefined`.
  7049. */
  7050. function getNative(object, key) {
  7051. var value = getValue(object, key);
  7052. return baseIsNative(value) ? value : undefined;
  7053. }
  7054. /**
  7055. * A specialized version of `baseGetTag` which ignores `Symbol.toStringTag` values.
  7056. *
  7057. * @private
  7058. * @param {*} value The value to query.
  7059. * @returns {string} Returns the raw `toStringTag`.
  7060. */
  7061. function getRawTag(value) {
  7062. var isOwn = hasOwnProperty.call(value, symToStringTag),
  7063. tag = value[symToStringTag];
  7064. try {
  7065. value[symToStringTag] = undefined;
  7066. var unmasked = true;
  7067. } catch (e) {}
  7068. var result = nativeObjectToString.call(value);
  7069. if (unmasked) {
  7070. if (isOwn) {
  7071. value[symToStringTag] = tag;
  7072. } else {
  7073. delete value[symToStringTag];
  7074. }
  7075. }
  7076. return result;
  7077. }
  7078. /**
  7079. * Creates an array of the own enumerable symbols of `object`.
  7080. *
  7081. * @private
  7082. * @param {Object} object The object to query.
  7083. * @returns {Array} Returns the array of symbols.
  7084. */
  7085. var getSymbols = !nativeGetSymbols ? stubArray : function(object) {
  7086. if (object == null) {
  7087. return [];
  7088. }
  7089. object = Object(object);
  7090. return arrayFilter(nativeGetSymbols(object), function(symbol) {
  7091. return propertyIsEnumerable.call(object, symbol);
  7092. });
  7093. };
  7094. /**
  7095. * Creates an array of the own and inherited enumerable symbols of `object`.
  7096. *
  7097. * @private
  7098. * @param {Object} object The object to query.
  7099. * @returns {Array} Returns the array of symbols.
  7100. */
  7101. var getSymbolsIn = !nativeGetSymbols ? stubArray : function(object) {
  7102. var result = [];
  7103. while (object) {
  7104. arrayPush(result, getSymbols(object));
  7105. object = getPrototype(object);
  7106. }
  7107. return result;
  7108. };
  7109. /**
  7110. * Gets the `toStringTag` of `value`.
  7111. *
  7112. * @private
  7113. * @param {*} value The value to query.
  7114. * @returns {string} Returns the `toStringTag`.
  7115. */
  7116. var getTag = baseGetTag;
  7117. // Fallback for data views, maps, sets, and weak maps in IE 11 and promises in Node.js < 6.
  7118. if ((DataView && getTag(new DataView(new ArrayBuffer(1))) != dataViewTag) ||
  7119. (Map && getTag(new Map) != mapTag) ||
  7120. (Promise && getTag(Promise.resolve()) != promiseTag) ||
  7121. (Set && getTag(new Set) != setTag) ||
  7122. (WeakMap && getTag(new WeakMap) != weakMapTag)) {
  7123. getTag = function(value) {
  7124. var result = baseGetTag(value),
  7125. Ctor = result == objectTag ? value.constructor : undefined,
  7126. ctorString = Ctor ? toSource(Ctor) : '';
  7127. if (ctorString) {
  7128. switch (ctorString) {
  7129. case dataViewCtorString: return dataViewTag;
  7130. case mapCtorString: return mapTag;
  7131. case promiseCtorString: return promiseTag;
  7132. case setCtorString: return setTag;
  7133. case weakMapCtorString: return weakMapTag;
  7134. }
  7135. }
  7136. return result;
  7137. };
  7138. }
  7139. /**
  7140. * Gets the view, applying any `transforms` to the `start` and `end` positions.
  7141. *
  7142. * @private
  7143. * @param {number} start The start of the view.
  7144. * @param {number} end The end of the view.
  7145. * @param {Array} transforms The transformations to apply to the view.
  7146. * @returns {Object} Returns an object containing the `start` and `end`
  7147. * positions of the view.
  7148. */
  7149. function getView(start, end, transforms) {
  7150. var index = -1,
  7151. length = transforms.length;
  7152. while (++index < length) {
  7153. var data = transforms[index],
  7154. size = data.size;
  7155. switch (data.type) {
  7156. case 'drop': start += size; break;
  7157. case 'dropRight': end -= size; break;
  7158. case 'take': end = nativeMin(end, start + size); break;
  7159. case 'takeRight': start = nativeMax(start, end - size); break;
  7160. }
  7161. }
  7162. return { 'start': start, 'end': end };
  7163. }
  7164. /**
  7165. * Extracts wrapper details from the `source` body comment.
  7166. *
  7167. * @private
  7168. * @param {string} source The source to inspect.
  7169. * @returns {Array} Returns the wrapper details.
  7170. */
  7171. function getWrapDetails(source) {
  7172. var match = source.match(reWrapDetails);
  7173. return match ? match[1].split(reSplitDetails) : [];
  7174. }
  7175. /**
  7176. * Checks if `path` exists on `object`.
  7177. *
  7178. * @private
  7179. * @param {Object} object The object to query.
  7180. * @param {Array|string} path The path to check.
  7181. * @param {Function} hasFunc The function to check properties.
  7182. * @returns {boolean} Returns `true` if `path` exists, else `false`.
  7183. */
  7184. function hasPath(object, path, hasFunc) {
  7185. path = castPath(path, object);
  7186. var index = -1,
  7187. length = path.length,
  7188. result = false;
  7189. while (++index < length) {
  7190. var key = toKey(path[index]);
  7191. if (!(result = object != null && hasFunc(object, key))) {
  7192. break;
  7193. }
  7194. object = object[key];
  7195. }
  7196. if (result || ++index != length) {
  7197. return result;
  7198. }
  7199. length = object == null ? 0 : object.length;
  7200. return !!length && isLength(length) && isIndex(key, length) &&
  7201. (isArray(object) || isArguments(object));
  7202. }
  7203. /**
  7204. * Initializes an array clone.
  7205. *
  7206. * @private
  7207. * @param {Array} array The array to clone.
  7208. * @returns {Array} Returns the initialized clone.
  7209. */
  7210. function initCloneArray(array) {
  7211. var length = array.length,
  7212. result = new array.constructor(length);
  7213. // Add properties assigned by `RegExp#exec`.
  7214. if (length && typeof array[0] == 'string' && hasOwnProperty.call(array, 'index')) {
  7215. result.index = array.index;
  7216. result.input = array.input;
  7217. }
  7218. return result;
  7219. }
  7220. /**
  7221. * Initializes an object clone.
  7222. *
  7223. * @private
  7224. * @param {Object} object The object to clone.
  7225. * @returns {Object} Returns the initialized clone.
  7226. */
  7227. function initCloneObject(object) {
  7228. return (typeof object.constructor == 'function' && !isPrototype(object))
  7229. ? baseCreate(getPrototype(object))
  7230. : {};
  7231. }
  7232. /**
  7233. * Initializes an object clone based on its `toStringTag`.
  7234. *
  7235. * **Note:** This function only supports cloning values with tags of
  7236. * `Boolean`, `Date`, `Error`, `Map`, `Number`, `RegExp`, `Set`, or `String`.
  7237. *
  7238. * @private
  7239. * @param {Object} object The object to clone.
  7240. * @param {string} tag The `toStringTag` of the object to clone.
  7241. * @param {boolean} [isDeep] Specify a deep clone.
  7242. * @returns {Object} Returns the initialized clone.
  7243. */
  7244. function initCloneByTag(object, tag, isDeep) {
  7245. var Ctor = object.constructor;
  7246. switch (tag) {
  7247. case arrayBufferTag:
  7248. return cloneArrayBuffer(object);
  7249. case boolTag:
  7250. case dateTag:
  7251. return new Ctor(+object);
  7252. case dataViewTag:
  7253. return cloneDataView(object, isDeep);
  7254. case float32Tag: case float64Tag:
  7255. case int8Tag: case int16Tag: case int32Tag:
  7256. case uint8Tag: case uint8ClampedTag: case uint16Tag: case uint32Tag:
  7257. return cloneTypedArray(object, isDeep);
  7258. case mapTag:
  7259. return new Ctor;
  7260. case numberTag:
  7261. case stringTag:
  7262. return new Ctor(object);
  7263. case regexpTag:
  7264. return cloneRegExp(object);
  7265. case setTag:
  7266. return new Ctor;
  7267. case symbolTag:
  7268. return cloneSymbol(object);
  7269. }
  7270. }
  7271. /**
  7272. * Inserts wrapper `details` in a comment at the top of the `source` body.
  7273. *
  7274. * @private
  7275. * @param {string} source The source to modify.
  7276. * @returns {Array} details The details to insert.
  7277. * @returns {string} Returns the modified source.
  7278. */
  7279. function insertWrapDetails(source, details) {
  7280. var length = details.length;
  7281. if (!length) {
  7282. return source;
  7283. }
  7284. var lastIndex = length - 1;
  7285. details[lastIndex] = (length > 1 ? '& ' : '') + details[lastIndex];
  7286. details = details.join(length > 2 ? ', ' : ' ');
  7287. return source.replace(reWrapComment, '{\n/* [wrapped with ' + details + '] */\n');
  7288. }
  7289. /**
  7290. * Checks if `value` is a flattenable `arguments` object or array.
  7291. *
  7292. * @private
  7293. * @param {*} value The value to check.
  7294. * @returns {boolean} Returns `true` if `value` is flattenable, else `false`.
  7295. */
  7296. function isFlattenable(value) {
  7297. return isArray(value) || isArguments(value) ||
  7298. !!(spreadableSymbol && value && value[spreadableSymbol]);
  7299. }
  7300. /**
  7301. * Checks if `value` is a valid array-like index.
  7302. *
  7303. * @private
  7304. * @param {*} value The value to check.
  7305. * @param {number} [length=MAX_SAFE_INTEGER] The upper bounds of a valid index.
  7306. * @returns {boolean} Returns `true` if `value` is a valid index, else `false`.
  7307. */
  7308. function isIndex(value, length) {
  7309. var type = typeof value;
  7310. length = length == null ? MAX_SAFE_INTEGER : length;
  7311. return !!length &&
  7312. (type == 'number' ||
  7313. (type != 'symbol' && reIsUint.test(value))) &&
  7314. (value > -1 && value % 1 == 0 && value < length);
  7315. }
  7316. /**
  7317. * Checks if the given arguments are from an iteratee call.
  7318. *
  7319. * @private
  7320. * @param {*} value The potential iteratee value argument.
  7321. * @param {*} index The potential iteratee index or key argument.
  7322. * @param {*} object The potential iteratee object argument.
  7323. * @returns {boolean} Returns `true` if the arguments are from an iteratee call,
  7324. * else `false`.
  7325. */
  7326. function isIterateeCall(value, index, object) {
  7327. if (!isObject(object)) {
  7328. return false;
  7329. }
  7330. var type = typeof index;
  7331. if (type == 'number'
  7332. ? (isArrayLike(object) && isIndex(index, object.length))
  7333. : (type == 'string' && index in object)
  7334. ) {
  7335. return eq(object[index], value);
  7336. }
  7337. return false;
  7338. }
  7339. /**
  7340. * Checks if `value` is a property name and not a property path.
  7341. *
  7342. * @private
  7343. * @param {*} value The value to check.
  7344. * @param {Object} [object] The object to query keys on.
  7345. * @returns {boolean} Returns `true` if `value` is a property name, else `false`.
  7346. */
  7347. function isKey(value, object) {
  7348. if (isArray(value)) {
  7349. return false;
  7350. }
  7351. var type = typeof value;
  7352. if (type == 'number' || type == 'symbol' || type == 'boolean' ||
  7353. value == null || isSymbol(value)) {
  7354. return true;
  7355. }
  7356. return reIsPlainProp.test(value) || !reIsDeepProp.test(value) ||
  7357. (object != null && value in Object(object));
  7358. }
  7359. /**
  7360. * Checks if `value` is suitable for use as unique object key.
  7361. *
  7362. * @private
  7363. * @param {*} value The value to check.
  7364. * @returns {boolean} Returns `true` if `value` is suitable, else `false`.
  7365. */
  7366. function isKeyable(value) {
  7367. var type = typeof value;
  7368. return (type == 'string' || type == 'number' || type == 'symbol' || type == 'boolean')
  7369. ? (value !== '__proto__')
  7370. : (value === null);
  7371. }
  7372. /**
  7373. * Checks if `func` has a lazy counterpart.
  7374. *
  7375. * @private
  7376. * @param {Function} func The function to check.
  7377. * @returns {boolean} Returns `true` if `func` has a lazy counterpart,
  7378. * else `false`.
  7379. */
  7380. function isLaziable(func) {
  7381. var funcName = getFuncName(func),
  7382. other = lodash[funcName];
  7383. if (typeof other != 'function' || !(funcName in LazyWrapper.prototype)) {
  7384. return false;
  7385. }
  7386. if (func === other) {
  7387. return true;
  7388. }
  7389. var data = getData(other);
  7390. return !!data && func === data[0];
  7391. }
  7392. /**
  7393. * Checks if `func` has its source masked.
  7394. *
  7395. * @private
  7396. * @param {Function} func The function to check.
  7397. * @returns {boolean} Returns `true` if `func` is masked, else `false`.
  7398. */
  7399. function isMasked(func) {
  7400. return !!maskSrcKey && (maskSrcKey in func);
  7401. }
  7402. /**
  7403. * Checks if `func` is capable of being masked.
  7404. *
  7405. * @private
  7406. * @param {*} value The value to check.
  7407. * @returns {boolean} Returns `true` if `func` is maskable, else `false`.
  7408. */
  7409. var isMaskable = coreJsData ? isFunction : stubFalse;
  7410. /**
  7411. * Checks if `value` is likely a prototype object.
  7412. *
  7413. * @private
  7414. * @param {*} value The value to check.
  7415. * @returns {boolean} Returns `true` if `value` is a prototype, else `false`.
  7416. */
  7417. function isPrototype(value) {
  7418. var Ctor = value && value.constructor,
  7419. proto = (typeof Ctor == 'function' && Ctor.prototype) || objectProto;
  7420. return value === proto;
  7421. }
  7422. /**
  7423. * Checks if `value` is suitable for strict equality comparisons, i.e. `===`.
  7424. *
  7425. * @private
  7426. * @param {*} value The value to check.
  7427. * @returns {boolean} Returns `true` if `value` if suitable for strict
  7428. * equality comparisons, else `false`.
  7429. */
  7430. function isStrictComparable(value) {
  7431. return value === value && !isObject(value);
  7432. }
  7433. /**
  7434. * A specialized version of `matchesProperty` for source values suitable
  7435. * for strict equality comparisons, i.e. `===`.
  7436. *
  7437. * @private
  7438. * @param {string} key The key of the property to get.
  7439. * @param {*} srcValue The value to match.
  7440. * @returns {Function} Returns the new spec function.
  7441. */
  7442. function matchesStrictComparable(key, srcValue) {
  7443. return function(object) {
  7444. if (object == null) {
  7445. return false;
  7446. }
  7447. return object[key] === srcValue &&
  7448. (srcValue !== undefined || (key in Object(object)));
  7449. };
  7450. }
  7451. /**
  7452. * A specialized version of `_.memoize` which clears the memoized function's
  7453. * cache when it exceeds `MAX_MEMOIZE_SIZE`.
  7454. *
  7455. * @private
  7456. * @param {Function} func The function to have its output memoized.
  7457. * @returns {Function} Returns the new memoized function.
  7458. */
  7459. function memoizeCapped(func) {
  7460. var result = memoize(func, function(key) {
  7461. if (cache.size === MAX_MEMOIZE_SIZE) {
  7462. cache.clear();
  7463. }
  7464. return key;
  7465. });
  7466. var cache = result.cache;
  7467. return result;
  7468. }
  7469. /**
  7470. * Merges the function metadata of `source` into `data`.
  7471. *
  7472. * Merging metadata reduces the number of wrappers used to invoke a function.
  7473. * This is possible because methods like `_.bind`, `_.curry`, and `_.partial`
  7474. * may be applied regardless of execution order. Methods like `_.ary` and
  7475. * `_.rearg` modify function arguments, making the order in which they are
  7476. * executed important, preventing the merging of metadata. However, we make
  7477. * an exception for a safe combined case where curried functions have `_.ary`
  7478. * and or `_.rearg` applied.
  7479. *
  7480. * @private
  7481. * @param {Array} data The destination metadata.
  7482. * @param {Array} source The source metadata.
  7483. * @returns {Array} Returns `data`.
  7484. */
  7485. function mergeData(data, source) {
  7486. var bitmask = data[1],
  7487. srcBitmask = source[1],
  7488. newBitmask = bitmask | srcBitmask,
  7489. isCommon = newBitmask < (WRAP_BIND_FLAG | WRAP_BIND_KEY_FLAG | WRAP_ARY_FLAG);
  7490. var isCombo =
  7491. ((srcBitmask == WRAP_ARY_FLAG) && (bitmask == WRAP_CURRY_FLAG)) ||
  7492. ((srcBitmask == WRAP_ARY_FLAG) && (bitmask == WRAP_REARG_FLAG) && (data[7].length <= source[8])) ||
  7493. ((srcBitmask == (WRAP_ARY_FLAG | WRAP_REARG_FLAG)) && (source[7].length <= source[8]) && (bitmask == WRAP_CURRY_FLAG));
  7494. // Exit early if metadata can't be merged.
  7495. if (!(isCommon || isCombo)) {
  7496. return data;
  7497. }
  7498. // Use source `thisArg` if available.
  7499. if (srcBitmask & WRAP_BIND_FLAG) {
  7500. data[2] = source[2];
  7501. // Set when currying a bound function.
  7502. newBitmask |= bitmask & WRAP_BIND_FLAG ? 0 : WRAP_CURRY_BOUND_FLAG;
  7503. }
  7504. // Compose partial arguments.
  7505. var value = source[3];
  7506. if (value) {
  7507. var partials = data[3];
  7508. data[3] = partials ? composeArgs(partials, value, source[4]) : value;
  7509. data[4] = partials ? replaceHolders(data[3], PLACEHOLDER) : source[4];
  7510. }
  7511. // Compose partial right arguments.
  7512. value = source[5];
  7513. if (value) {
  7514. partials = data[5];
  7515. data[5] = partials ? composeArgsRight(partials, value, source[6]) : value;
  7516. data[6] = partials ? replaceHolders(data[5], PLACEHOLDER) : source[6];
  7517. }
  7518. // Use source `argPos` if available.
  7519. value = source[7];
  7520. if (value) {
  7521. data[7] = value;
  7522. }
  7523. // Use source `ary` if it's smaller.
  7524. if (srcBitmask & WRAP_ARY_FLAG) {
  7525. data[8] = data[8] == null ? source[8] : nativeMin(data[8], source[8]);
  7526. }
  7527. // Use source `arity` if one is not provided.
  7528. if (data[9] == null) {
  7529. data[9] = source[9];
  7530. }
  7531. // Use source `func` and merge bitmasks.
  7532. data[0] = source[0];
  7533. data[1] = newBitmask;
  7534. return data;
  7535. }
  7536. /**
  7537. * This function is like
  7538. * [`Object.keys`](http://ecma-international.org/ecma-262/7.0/#sec-object.keys)
  7539. * except that it includes inherited enumerable properties.
  7540. *
  7541. * @private
  7542. * @param {Object} object The object to query.
  7543. * @returns {Array} Returns the array of property names.
  7544. */
  7545. function nativeKeysIn(object) {
  7546. var result = [];
  7547. if (object != null) {
  7548. for (var key in Object(object)) {
  7549. result.push(key);
  7550. }
  7551. }
  7552. return result;
  7553. }
  7554. /**
  7555. * Converts `value` to a string using `Object.prototype.toString`.
  7556. *
  7557. * @private
  7558. * @param {*} value The value to convert.
  7559. * @returns {string} Returns the converted string.
  7560. */
  7561. function objectToString(value) {
  7562. return nativeObjectToString.call(value);
  7563. }
  7564. /**
  7565. * A specialized version of `baseRest` which transforms the rest array.
  7566. *
  7567. * @private
  7568. * @param {Function} func The function to apply a rest parameter to.
  7569. * @param {number} [start=func.length-1] The start position of the rest parameter.
  7570. * @param {Function} transform The rest array transform.
  7571. * @returns {Function} Returns the new function.
  7572. */
  7573. function overRest(func, start, transform) {
  7574. start = nativeMax(start === undefined ? (func.length - 1) : start, 0);
  7575. return function() {
  7576. var args = arguments,
  7577. index = -1,
  7578. length = nativeMax(args.length - start, 0),
  7579. array = Array(length);
  7580. while (++index < length) {
  7581. array[index] = args[start + index];
  7582. }
  7583. index = -1;
  7584. var otherArgs = Array(start + 1);
  7585. while (++index < start) {
  7586. otherArgs[index] = args[index];
  7587. }
  7588. otherArgs[start] = transform(array);
  7589. return apply(func, this, otherArgs);
  7590. };
  7591. }
  7592. /**
  7593. * Gets the parent value at `path` of `object`.
  7594. *
  7595. * @private
  7596. * @param {Object} object The object to query.
  7597. * @param {Array} path The path to get the parent value of.
  7598. * @returns {*} Returns the parent value.
  7599. */
  7600. function parent(object, path) {
  7601. return path.length < 2 ? object : baseGet(object, baseSlice(path, 0, -1));
  7602. }
  7603. /**
  7604. * Reorder `array` according to the specified indexes where the element at
  7605. * the first index is assigned as the first element, the element at
  7606. * the second index is assigned as the second element, and so on.
  7607. *
  7608. * @private
  7609. * @param {Array} array The array to reorder.
  7610. * @param {Array} indexes The arranged array indexes.
  7611. * @returns {Array} Returns `array`.
  7612. */
  7613. function reorder(array, indexes) {
  7614. var arrLength = array.length,
  7615. length = nativeMin(indexes.length, arrLength),
  7616. oldArray = copyArray(array);
  7617. while (length--) {
  7618. var index = indexes[length];
  7619. array[length] = isIndex(index, arrLength) ? oldArray[index] : undefined;
  7620. }
  7621. return array;
  7622. }
  7623. /**
  7624. * Gets the value at `key`, unless `key` is "__proto__" or "constructor".
  7625. *
  7626. * @private
  7627. * @param {Object} object The object to query.
  7628. * @param {string} key The key of the property to get.
  7629. * @returns {*} Returns the property value.
  7630. */
  7631. function safeGet(object, key) {
  7632. if (key === 'constructor' && typeof object[key] === 'function') {
  7633. return;
  7634. }
  7635. if (key == '__proto__') {
  7636. return;
  7637. }
  7638. return object[key];
  7639. }
  7640. /**
  7641. * Sets metadata for `func`.
  7642. *
  7643. * **Note:** If this function becomes hot, i.e. is invoked a lot in a short
  7644. * period of time, it will trip its breaker and transition to an identity
  7645. * function to avoid garbage collection pauses in V8. See
  7646. * [V8 issue 2070](https://bugs.chromium.org/p/v8/issues/detail?id=2070)
  7647. * for more details.
  7648. *
  7649. * @private
  7650. * @param {Function} func The function to associate metadata with.
  7651. * @param {*} data The metadata.
  7652. * @returns {Function} Returns `func`.
  7653. */
  7654. var setData = shortOut(baseSetData);
  7655. /**
  7656. * A simple wrapper around the global [`setTimeout`](https://mdn.io/setTimeout).
  7657. *
  7658. * @private
  7659. * @param {Function} func The function to delay.
  7660. * @param {number} wait The number of milliseconds to delay invocation.
  7661. * @returns {number|Object} Returns the timer id or timeout object.
  7662. */
  7663. var setTimeout = ctxSetTimeout || function(func, wait) {
  7664. return root.setTimeout(func, wait);
  7665. };
  7666. /**
  7667. * Sets the `toString` method of `func` to return `string`.
  7668. *
  7669. * @private
  7670. * @param {Function} func The function to modify.
  7671. * @param {Function} string The `toString` result.
  7672. * @returns {Function} Returns `func`.
  7673. */
  7674. var setToString = shortOut(baseSetToString);
  7675. /**
  7676. * Sets the `toString` method of `wrapper` to mimic the source of `reference`
  7677. * with wrapper details in a comment at the top of the source body.
  7678. *
  7679. * @private
  7680. * @param {Function} wrapper The function to modify.
  7681. * @param {Function} reference The reference function.
  7682. * @param {number} bitmask The bitmask flags. See `createWrap` for more details.
  7683. * @returns {Function} Returns `wrapper`.
  7684. */
  7685. function setWrapToString(wrapper, reference, bitmask) {
  7686. var source = (reference + '');
  7687. return setToString(wrapper, insertWrapDetails(source, updateWrapDetails(getWrapDetails(source), bitmask)));
  7688. }
  7689. /**
  7690. * Creates a function that'll short out and invoke `identity` instead
  7691. * of `func` when it's called `HOT_COUNT` or more times in `HOT_SPAN`
  7692. * milliseconds.
  7693. *
  7694. * @private
  7695. * @param {Function} func The function to restrict.
  7696. * @returns {Function} Returns the new shortable function.
  7697. */
  7698. function shortOut(func) {
  7699. var count = 0,
  7700. lastCalled = 0;
  7701. return function() {
  7702. var stamp = nativeNow(),
  7703. remaining = HOT_SPAN - (stamp - lastCalled);
  7704. lastCalled = stamp;
  7705. if (remaining > 0) {
  7706. if (++count >= HOT_COUNT) {
  7707. return arguments[0];
  7708. }
  7709. } else {
  7710. count = 0;
  7711. }
  7712. return func.apply(undefined, arguments);
  7713. };
  7714. }
  7715. /**
  7716. * A specialized version of `_.shuffle` which mutates and sets the size of `array`.
  7717. *
  7718. * @private
  7719. * @param {Array} array The array to shuffle.
  7720. * @param {number} [size=array.length] The size of `array`.
  7721. * @returns {Array} Returns `array`.
  7722. */
  7723. function shuffleSelf(array, size) {
  7724. var index = -1,
  7725. length = array.length,
  7726. lastIndex = length - 1;
  7727. size = size === undefined ? length : size;
  7728. while (++index < size) {
  7729. var rand = baseRandom(index, lastIndex),
  7730. value = array[rand];
  7731. array[rand] = array[index];
  7732. array[index] = value;
  7733. }
  7734. array.length = size;
  7735. return array;
  7736. }
  7737. /**
  7738. * Converts `string` to a property path array.
  7739. *
  7740. * @private
  7741. * @param {string} string The string to convert.
  7742. * @returns {Array} Returns the property path array.
  7743. */
  7744. var stringToPath = memoizeCapped(function(string) {
  7745. var result = [];
  7746. if (string.charCodeAt(0) === 46 /* . */) {
  7747. result.push('');
  7748. }
  7749. string.replace(rePropName, function(match, number, quote, subString) {
  7750. result.push(quote ? subString.replace(reEscapeChar, '$1') : (number || match));
  7751. });
  7752. return result;
  7753. });
  7754. /**
  7755. * Converts `value` to a string key if it's not a string or symbol.
  7756. *
  7757. * @private
  7758. * @param {*} value The value to inspect.
  7759. * @returns {string|symbol} Returns the key.
  7760. */
  7761. function toKey(value) {
  7762. if (typeof value == 'string' || isSymbol(value)) {
  7763. return value;
  7764. }
  7765. var result = (value + '');
  7766. return (result == '0' && (1 / value) == -INFINITY) ? '-0' : result;
  7767. }
  7768. /**
  7769. * Converts `func` to its source code.
  7770. *
  7771. * @private
  7772. * @param {Function} func The function to convert.
  7773. * @returns {string} Returns the source code.
  7774. */
  7775. function toSource(func) {
  7776. if (func != null) {
  7777. try {
  7778. return funcToString.call(func);
  7779. } catch (e) {}
  7780. try {
  7781. return (func + '');
  7782. } catch (e) {}
  7783. }
  7784. return '';
  7785. }
  7786. /**
  7787. * Updates wrapper `details` based on `bitmask` flags.
  7788. *
  7789. * @private
  7790. * @returns {Array} details The details to modify.
  7791. * @param {number} bitmask The bitmask flags. See `createWrap` for more details.
  7792. * @returns {Array} Returns `details`.
  7793. */
  7794. function updateWrapDetails(details, bitmask) {
  7795. arrayEach(wrapFlags, function(pair) {
  7796. var value = '_.' + pair[0];
  7797. if ((bitmask & pair[1]) && !arrayIncludes(details, value)) {
  7798. details.push(value);
  7799. }
  7800. });
  7801. return details.sort();
  7802. }
  7803. /**
  7804. * Creates a clone of `wrapper`.
  7805. *
  7806. * @private
  7807. * @param {Object} wrapper The wrapper to clone.
  7808. * @returns {Object} Returns the cloned wrapper.
  7809. */
  7810. function wrapperClone(wrapper) {
  7811. if (wrapper instanceof LazyWrapper) {
  7812. return wrapper.clone();
  7813. }
  7814. var result = new LodashWrapper(wrapper.__wrapped__, wrapper.__chain__);
  7815. result.__actions__ = copyArray(wrapper.__actions__);
  7816. result.__index__ = wrapper.__index__;
  7817. result.__values__ = wrapper.__values__;
  7818. return result;
  7819. }
  7820. /*------------------------------------------------------------------------*/
  7821. /**
  7822. * Creates an array of elements split into groups the length of `size`.
  7823. * If `array` can't be split evenly, the final chunk will be the remaining
  7824. * elements.
  7825. *
  7826. * @static
  7827. * @memberOf _
  7828. * @since 3.0.0
  7829. * @category Array
  7830. * @param {Array} array The array to process.
  7831. * @param {number} [size=1] The length of each chunk
  7832. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  7833. * @returns {Array} Returns the new array of chunks.
  7834. * @example
  7835. *
  7836. * _.chunk(['a', 'b', 'c', 'd'], 2);
  7837. * // => [['a', 'b'], ['c', 'd']]
  7838. *
  7839. * _.chunk(['a', 'b', 'c', 'd'], 3);
  7840. * // => [['a', 'b', 'c'], ['d']]
  7841. */
  7842. function chunk(array, size, guard) {
  7843. if ((guard ? isIterateeCall(array, size, guard) : size === undefined)) {
  7844. size = 1;
  7845. } else {
  7846. size = nativeMax(toInteger(size), 0);
  7847. }
  7848. var length = array == null ? 0 : array.length;
  7849. if (!length || size < 1) {
  7850. return [];
  7851. }
  7852. var index = 0,
  7853. resIndex = 0,
  7854. result = Array(nativeCeil(length / size));
  7855. while (index < length) {
  7856. result[resIndex++] = baseSlice(array, index, (index += size));
  7857. }
  7858. return result;
  7859. }
  7860. /**
  7861. * Creates an array with all falsey values removed. The values `false`, `null`,
  7862. * `0`, `""`, `undefined`, and `NaN` are falsey.
  7863. *
  7864. * @static
  7865. * @memberOf _
  7866. * @since 0.1.0
  7867. * @category Array
  7868. * @param {Array} array The array to compact.
  7869. * @returns {Array} Returns the new array of filtered values.
  7870. * @example
  7871. *
  7872. * _.compact([0, 1, false, 2, '', 3]);
  7873. * // => [1, 2, 3]
  7874. */
  7875. function compact(array) {
  7876. var index = -1,
  7877. length = array == null ? 0 : array.length,
  7878. resIndex = 0,
  7879. result = [];
  7880. while (++index < length) {
  7881. var value = array[index];
  7882. if (value) {
  7883. result[resIndex++] = value;
  7884. }
  7885. }
  7886. return result;
  7887. }
  7888. /**
  7889. * Creates a new array concatenating `array` with any additional arrays
  7890. * and/or values.
  7891. *
  7892. * @static
  7893. * @memberOf _
  7894. * @since 4.0.0
  7895. * @category Array
  7896. * @param {Array} array The array to concatenate.
  7897. * @param {...*} [values] The values to concatenate.
  7898. * @returns {Array} Returns the new concatenated array.
  7899. * @example
  7900. *
  7901. * var array = [1];
  7902. * var other = _.concat(array, 2, [3], [[4]]);
  7903. *
  7904. * console.log(other);
  7905. * // => [1, 2, 3, [4]]
  7906. *
  7907. * console.log(array);
  7908. * // => [1]
  7909. */
  7910. function concat() {
  7911. var length = arguments.length;
  7912. if (!length) {
  7913. return [];
  7914. }
  7915. var args = Array(length - 1),
  7916. array = arguments[0],
  7917. index = length;
  7918. while (index--) {
  7919. args[index - 1] = arguments[index];
  7920. }
  7921. return arrayPush(isArray(array) ? copyArray(array) : [array], baseFlatten(args, 1));
  7922. }
  7923. /**
  7924. * Creates an array of `array` values not included in the other given arrays
  7925. * using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
  7926. * for equality comparisons. The order and references of result values are
  7927. * determined by the first array.
  7928. *
  7929. * **Note:** Unlike `_.pullAll`, this method returns a new array.
  7930. *
  7931. * @static
  7932. * @memberOf _
  7933. * @since 0.1.0
  7934. * @category Array
  7935. * @param {Array} array The array to inspect.
  7936. * @param {...Array} [values] The values to exclude.
  7937. * @returns {Array} Returns the new array of filtered values.
  7938. * @see _.without, _.xor
  7939. * @example
  7940. *
  7941. * _.difference([2, 1], [2, 3]);
  7942. * // => [1]
  7943. */
  7944. var difference = baseRest(function(array, values) {
  7945. return isArrayLikeObject(array)
  7946. ? baseDifference(array, baseFlatten(values, 1, isArrayLikeObject, true))
  7947. : [];
  7948. });
  7949. /**
  7950. * This method is like `_.difference` except that it accepts `iteratee` which
  7951. * is invoked for each element of `array` and `values` to generate the criterion
  7952. * by which they're compared. The order and references of result values are
  7953. * determined by the first array. The iteratee is invoked with one argument:
  7954. * (value).
  7955. *
  7956. * **Note:** Unlike `_.pullAllBy`, this method returns a new array.
  7957. *
  7958. * @static
  7959. * @memberOf _
  7960. * @since 4.0.0
  7961. * @category Array
  7962. * @param {Array} array The array to inspect.
  7963. * @param {...Array} [values] The values to exclude.
  7964. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  7965. * @returns {Array} Returns the new array of filtered values.
  7966. * @example
  7967. *
  7968. * _.differenceBy([2.1, 1.2], [2.3, 3.4], Math.floor);
  7969. * // => [1.2]
  7970. *
  7971. * // The `_.property` iteratee shorthand.
  7972. * _.differenceBy([{ 'x': 2 }, { 'x': 1 }], [{ 'x': 1 }], 'x');
  7973. * // => [{ 'x': 2 }]
  7974. */
  7975. var differenceBy = baseRest(function(array, values) {
  7976. var iteratee = last(values);
  7977. if (isArrayLikeObject(iteratee)) {
  7978. iteratee = undefined;
  7979. }
  7980. return isArrayLikeObject(array)
  7981. ? baseDifference(array, baseFlatten(values, 1, isArrayLikeObject, true), getIteratee(iteratee, 2))
  7982. : [];
  7983. });
  7984. /**
  7985. * This method is like `_.difference` except that it accepts `comparator`
  7986. * which is invoked to compare elements of `array` to `values`. The order and
  7987. * references of result values are determined by the first array. The comparator
  7988. * is invoked with two arguments: (arrVal, othVal).
  7989. *
  7990. * **Note:** Unlike `_.pullAllWith`, this method returns a new array.
  7991. *
  7992. * @static
  7993. * @memberOf _
  7994. * @since 4.0.0
  7995. * @category Array
  7996. * @param {Array} array The array to inspect.
  7997. * @param {...Array} [values] The values to exclude.
  7998. * @param {Function} [comparator] The comparator invoked per element.
  7999. * @returns {Array} Returns the new array of filtered values.
  8000. * @example
  8001. *
  8002. * var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }];
  8003. *
  8004. * _.differenceWith(objects, [{ 'x': 1, 'y': 2 }], _.isEqual);
  8005. * // => [{ 'x': 2, 'y': 1 }]
  8006. */
  8007. var differenceWith = baseRest(function(array, values) {
  8008. var comparator = last(values);
  8009. if (isArrayLikeObject(comparator)) {
  8010. comparator = undefined;
  8011. }
  8012. return isArrayLikeObject(array)
  8013. ? baseDifference(array, baseFlatten(values, 1, isArrayLikeObject, true), undefined, comparator)
  8014. : [];
  8015. });
  8016. /**
  8017. * Creates a slice of `array` with `n` elements dropped from the beginning.
  8018. *
  8019. * @static
  8020. * @memberOf _
  8021. * @since 0.5.0
  8022. * @category Array
  8023. * @param {Array} array The array to query.
  8024. * @param {number} [n=1] The number of elements to drop.
  8025. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  8026. * @returns {Array} Returns the slice of `array`.
  8027. * @example
  8028. *
  8029. * _.drop([1, 2, 3]);
  8030. * // => [2, 3]
  8031. *
  8032. * _.drop([1, 2, 3], 2);
  8033. * // => [3]
  8034. *
  8035. * _.drop([1, 2, 3], 5);
  8036. * // => []
  8037. *
  8038. * _.drop([1, 2, 3], 0);
  8039. * // => [1, 2, 3]
  8040. */
  8041. function drop(array, n, guard) {
  8042. var length = array == null ? 0 : array.length;
  8043. if (!length) {
  8044. return [];
  8045. }
  8046. n = (guard || n === undefined) ? 1 : toInteger(n);
  8047. return baseSlice(array, n < 0 ? 0 : n, length);
  8048. }
  8049. /**
  8050. * Creates a slice of `array` with `n` elements dropped from the end.
  8051. *
  8052. * @static
  8053. * @memberOf _
  8054. * @since 3.0.0
  8055. * @category Array
  8056. * @param {Array} array The array to query.
  8057. * @param {number} [n=1] The number of elements to drop.
  8058. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  8059. * @returns {Array} Returns the slice of `array`.
  8060. * @example
  8061. *
  8062. * _.dropRight([1, 2, 3]);
  8063. * // => [1, 2]
  8064. *
  8065. * _.dropRight([1, 2, 3], 2);
  8066. * // => [1]
  8067. *
  8068. * _.dropRight([1, 2, 3], 5);
  8069. * // => []
  8070. *
  8071. * _.dropRight([1, 2, 3], 0);
  8072. * // => [1, 2, 3]
  8073. */
  8074. function dropRight(array, n, guard) {
  8075. var length = array == null ? 0 : array.length;
  8076. if (!length) {
  8077. return [];
  8078. }
  8079. n = (guard || n === undefined) ? 1 : toInteger(n);
  8080. n = length - n;
  8081. return baseSlice(array, 0, n < 0 ? 0 : n);
  8082. }
  8083. /**
  8084. * Creates a slice of `array` excluding elements dropped from the end.
  8085. * Elements are dropped until `predicate` returns falsey. The predicate is
  8086. * invoked with three arguments: (value, index, array).
  8087. *
  8088. * @static
  8089. * @memberOf _
  8090. * @since 3.0.0
  8091. * @category Array
  8092. * @param {Array} array The array to query.
  8093. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  8094. * @returns {Array} Returns the slice of `array`.
  8095. * @example
  8096. *
  8097. * var users = [
  8098. * { 'user': 'barney', 'active': true },
  8099. * { 'user': 'fred', 'active': false },
  8100. * { 'user': 'pebbles', 'active': false }
  8101. * ];
  8102. *
  8103. * _.dropRightWhile(users, function(o) { return !o.active; });
  8104. * // => objects for ['barney']
  8105. *
  8106. * // The `_.matches` iteratee shorthand.
  8107. * _.dropRightWhile(users, { 'user': 'pebbles', 'active': false });
  8108. * // => objects for ['barney', 'fred']
  8109. *
  8110. * // The `_.matchesProperty` iteratee shorthand.
  8111. * _.dropRightWhile(users, ['active', false]);
  8112. * // => objects for ['barney']
  8113. *
  8114. * // The `_.property` iteratee shorthand.
  8115. * _.dropRightWhile(users, 'active');
  8116. * // => objects for ['barney', 'fred', 'pebbles']
  8117. */
  8118. function dropRightWhile(array, predicate) {
  8119. return (array && array.length)
  8120. ? baseWhile(array, getIteratee(predicate, 3), true, true)
  8121. : [];
  8122. }
  8123. /**
  8124. * Creates a slice of `array` excluding elements dropped from the beginning.
  8125. * Elements are dropped until `predicate` returns falsey. The predicate is
  8126. * invoked with three arguments: (value, index, array).
  8127. *
  8128. * @static
  8129. * @memberOf _
  8130. * @since 3.0.0
  8131. * @category Array
  8132. * @param {Array} array The array to query.
  8133. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  8134. * @returns {Array} Returns the slice of `array`.
  8135. * @example
  8136. *
  8137. * var users = [
  8138. * { 'user': 'barney', 'active': false },
  8139. * { 'user': 'fred', 'active': false },
  8140. * { 'user': 'pebbles', 'active': true }
  8141. * ];
  8142. *
  8143. * _.dropWhile(users, function(o) { return !o.active; });
  8144. * // => objects for ['pebbles']
  8145. *
  8146. * // The `_.matches` iteratee shorthand.
  8147. * _.dropWhile(users, { 'user': 'barney', 'active': false });
  8148. * // => objects for ['fred', 'pebbles']
  8149. *
  8150. * // The `_.matchesProperty` iteratee shorthand.
  8151. * _.dropWhile(users, ['active', false]);
  8152. * // => objects for ['pebbles']
  8153. *
  8154. * // The `_.property` iteratee shorthand.
  8155. * _.dropWhile(users, 'active');
  8156. * // => objects for ['barney', 'fred', 'pebbles']
  8157. */
  8158. function dropWhile(array, predicate) {
  8159. return (array && array.length)
  8160. ? baseWhile(array, getIteratee(predicate, 3), true)
  8161. : [];
  8162. }
  8163. /**
  8164. * Fills elements of `array` with `value` from `start` up to, but not
  8165. * including, `end`.
  8166. *
  8167. * **Note:** This method mutates `array`.
  8168. *
  8169. * @static
  8170. * @memberOf _
  8171. * @since 3.2.0
  8172. * @category Array
  8173. * @param {Array} array The array to fill.
  8174. * @param {*} value The value to fill `array` with.
  8175. * @param {number} [start=0] The start position.
  8176. * @param {number} [end=array.length] The end position.
  8177. * @returns {Array} Returns `array`.
  8178. * @example
  8179. *
  8180. * var array = [1, 2, 3];
  8181. *
  8182. * _.fill(array, 'a');
  8183. * console.log(array);
  8184. * // => ['a', 'a', 'a']
  8185. *
  8186. * _.fill(Array(3), 2);
  8187. * // => [2, 2, 2]
  8188. *
  8189. * _.fill([4, 6, 8, 10], '*', 1, 3);
  8190. * // => [4, '*', '*', 10]
  8191. */
  8192. function fill(array, value, start, end) {
  8193. var length = array == null ? 0 : array.length;
  8194. if (!length) {
  8195. return [];
  8196. }
  8197. if (start && typeof start != 'number' && isIterateeCall(array, value, start)) {
  8198. start = 0;
  8199. end = length;
  8200. }
  8201. return baseFill(array, value, start, end);
  8202. }
  8203. /**
  8204. * This method is like `_.find` except that it returns the index of the first
  8205. * element `predicate` returns truthy for instead of the element itself.
  8206. *
  8207. * @static
  8208. * @memberOf _
  8209. * @since 1.1.0
  8210. * @category Array
  8211. * @param {Array} array The array to inspect.
  8212. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  8213. * @param {number} [fromIndex=0] The index to search from.
  8214. * @returns {number} Returns the index of the found element, else `-1`.
  8215. * @example
  8216. *
  8217. * var users = [
  8218. * { 'user': 'barney', 'active': false },
  8219. * { 'user': 'fred', 'active': false },
  8220. * { 'user': 'pebbles', 'active': true }
  8221. * ];
  8222. *
  8223. * _.findIndex(users, function(o) { return o.user == 'barney'; });
  8224. * // => 0
  8225. *
  8226. * // The `_.matches` iteratee shorthand.
  8227. * _.findIndex(users, { 'user': 'fred', 'active': false });
  8228. * // => 1
  8229. *
  8230. * // The `_.matchesProperty` iteratee shorthand.
  8231. * _.findIndex(users, ['active', false]);
  8232. * // => 0
  8233. *
  8234. * // The `_.property` iteratee shorthand.
  8235. * _.findIndex(users, 'active');
  8236. * // => 2
  8237. */
  8238. function findIndex(array, predicate, fromIndex) {
  8239. var length = array == null ? 0 : array.length;
  8240. if (!length) {
  8241. return -1;
  8242. }
  8243. var index = fromIndex == null ? 0 : toInteger(fromIndex);
  8244. if (index < 0) {
  8245. index = nativeMax(length + index, 0);
  8246. }
  8247. return baseFindIndex(array, getIteratee(predicate, 3), index);
  8248. }
  8249. /**
  8250. * This method is like `_.findIndex` except that it iterates over elements
  8251. * of `collection` from right to left.
  8252. *
  8253. * @static
  8254. * @memberOf _
  8255. * @since 2.0.0
  8256. * @category Array
  8257. * @param {Array} array The array to inspect.
  8258. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  8259. * @param {number} [fromIndex=array.length-1] The index to search from.
  8260. * @returns {number} Returns the index of the found element, else `-1`.
  8261. * @example
  8262. *
  8263. * var users = [
  8264. * { 'user': 'barney', 'active': true },
  8265. * { 'user': 'fred', 'active': false },
  8266. * { 'user': 'pebbles', 'active': false }
  8267. * ];
  8268. *
  8269. * _.findLastIndex(users, function(o) { return o.user == 'pebbles'; });
  8270. * // => 2
  8271. *
  8272. * // The `_.matches` iteratee shorthand.
  8273. * _.findLastIndex(users, { 'user': 'barney', 'active': true });
  8274. * // => 0
  8275. *
  8276. * // The `_.matchesProperty` iteratee shorthand.
  8277. * _.findLastIndex(users, ['active', false]);
  8278. * // => 2
  8279. *
  8280. * // The `_.property` iteratee shorthand.
  8281. * _.findLastIndex(users, 'active');
  8282. * // => 0
  8283. */
  8284. function findLastIndex(array, predicate, fromIndex) {
  8285. var length = array == null ? 0 : array.length;
  8286. if (!length) {
  8287. return -1;
  8288. }
  8289. var index = length - 1;
  8290. if (fromIndex !== undefined) {
  8291. index = toInteger(fromIndex);
  8292. index = fromIndex < 0
  8293. ? nativeMax(length + index, 0)
  8294. : nativeMin(index, length - 1);
  8295. }
  8296. return baseFindIndex(array, getIteratee(predicate, 3), index, true);
  8297. }
  8298. /**
  8299. * Flattens `array` a single level deep.
  8300. *
  8301. * @static
  8302. * @memberOf _
  8303. * @since 0.1.0
  8304. * @category Array
  8305. * @param {Array} array The array to flatten.
  8306. * @returns {Array} Returns the new flattened array.
  8307. * @example
  8308. *
  8309. * _.flatten([1, [2, [3, [4]], 5]]);
  8310. * // => [1, 2, [3, [4]], 5]
  8311. */
  8312. function flatten(array) {
  8313. var length = array == null ? 0 : array.length;
  8314. return length ? baseFlatten(array, 1) : [];
  8315. }
  8316. /**
  8317. * Recursively flattens `array`.
  8318. *
  8319. * @static
  8320. * @memberOf _
  8321. * @since 3.0.0
  8322. * @category Array
  8323. * @param {Array} array The array to flatten.
  8324. * @returns {Array} Returns the new flattened array.
  8325. * @example
  8326. *
  8327. * _.flattenDeep([1, [2, [3, [4]], 5]]);
  8328. * // => [1, 2, 3, 4, 5]
  8329. */
  8330. function flattenDeep(array) {
  8331. var length = array == null ? 0 : array.length;
  8332. return length ? baseFlatten(array, INFINITY) : [];
  8333. }
  8334. /**
  8335. * Recursively flatten `array` up to `depth` times.
  8336. *
  8337. * @static
  8338. * @memberOf _
  8339. * @since 4.4.0
  8340. * @category Array
  8341. * @param {Array} array The array to flatten.
  8342. * @param {number} [depth=1] The maximum recursion depth.
  8343. * @returns {Array} Returns the new flattened array.
  8344. * @example
  8345. *
  8346. * var array = [1, [2, [3, [4]], 5]];
  8347. *
  8348. * _.flattenDepth(array, 1);
  8349. * // => [1, 2, [3, [4]], 5]
  8350. *
  8351. * _.flattenDepth(array, 2);
  8352. * // => [1, 2, 3, [4], 5]
  8353. */
  8354. function flattenDepth(array, depth) {
  8355. var length = array == null ? 0 : array.length;
  8356. if (!length) {
  8357. return [];
  8358. }
  8359. depth = depth === undefined ? 1 : toInteger(depth);
  8360. return baseFlatten(array, depth);
  8361. }
  8362. /**
  8363. * The inverse of `_.toPairs`; this method returns an object composed
  8364. * from key-value `pairs`.
  8365. *
  8366. * @static
  8367. * @memberOf _
  8368. * @since 4.0.0
  8369. * @category Array
  8370. * @param {Array} pairs The key-value pairs.
  8371. * @returns {Object} Returns the new object.
  8372. * @example
  8373. *
  8374. * _.fromPairs([['a', 1], ['b', 2]]);
  8375. * // => { 'a': 1, 'b': 2 }
  8376. */
  8377. function fromPairs(pairs) {
  8378. var index = -1,
  8379. length = pairs == null ? 0 : pairs.length,
  8380. result = {};
  8381. while (++index < length) {
  8382. var pair = pairs[index];
  8383. result[pair[0]] = pair[1];
  8384. }
  8385. return result;
  8386. }
  8387. /**
  8388. * Gets the first element of `array`.
  8389. *
  8390. * @static
  8391. * @memberOf _
  8392. * @since 0.1.0
  8393. * @alias first
  8394. * @category Array
  8395. * @param {Array} array The array to query.
  8396. * @returns {*} Returns the first element of `array`.
  8397. * @example
  8398. *
  8399. * _.head([1, 2, 3]);
  8400. * // => 1
  8401. *
  8402. * _.head([]);
  8403. * // => undefined
  8404. */
  8405. function head(array) {
  8406. return (array && array.length) ? array[0] : undefined;
  8407. }
  8408. /**
  8409. * Gets the index at which the first occurrence of `value` is found in `array`
  8410. * using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
  8411. * for equality comparisons. If `fromIndex` is negative, it's used as the
  8412. * offset from the end of `array`.
  8413. *
  8414. * @static
  8415. * @memberOf _
  8416. * @since 0.1.0
  8417. * @category Array
  8418. * @param {Array} array The array to inspect.
  8419. * @param {*} value The value to search for.
  8420. * @param {number} [fromIndex=0] The index to search from.
  8421. * @returns {number} Returns the index of the matched value, else `-1`.
  8422. * @example
  8423. *
  8424. * _.indexOf([1, 2, 1, 2], 2);
  8425. * // => 1
  8426. *
  8427. * // Search from the `fromIndex`.
  8428. * _.indexOf([1, 2, 1, 2], 2, 2);
  8429. * // => 3
  8430. */
  8431. function indexOf(array, value, fromIndex) {
  8432. var length = array == null ? 0 : array.length;
  8433. if (!length) {
  8434. return -1;
  8435. }
  8436. var index = fromIndex == null ? 0 : toInteger(fromIndex);
  8437. if (index < 0) {
  8438. index = nativeMax(length + index, 0);
  8439. }
  8440. return baseIndexOf(array, value, index);
  8441. }
  8442. /**
  8443. * Gets all but the last element of `array`.
  8444. *
  8445. * @static
  8446. * @memberOf _
  8447. * @since 0.1.0
  8448. * @category Array
  8449. * @param {Array} array The array to query.
  8450. * @returns {Array} Returns the slice of `array`.
  8451. * @example
  8452. *
  8453. * _.initial([1, 2, 3]);
  8454. * // => [1, 2]
  8455. */
  8456. function initial(array) {
  8457. var length = array == null ? 0 : array.length;
  8458. return length ? baseSlice(array, 0, -1) : [];
  8459. }
  8460. /**
  8461. * Creates an array of unique values that are included in all given arrays
  8462. * using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
  8463. * for equality comparisons. The order and references of result values are
  8464. * determined by the first array.
  8465. *
  8466. * @static
  8467. * @memberOf _
  8468. * @since 0.1.0
  8469. * @category Array
  8470. * @param {...Array} [arrays] The arrays to inspect.
  8471. * @returns {Array} Returns the new array of intersecting values.
  8472. * @example
  8473. *
  8474. * _.intersection([2, 1], [2, 3]);
  8475. * // => [2]
  8476. */
  8477. var intersection = baseRest(function(arrays) {
  8478. var mapped = arrayMap(arrays, castArrayLikeObject);
  8479. return (mapped.length && mapped[0] === arrays[0])
  8480. ? baseIntersection(mapped)
  8481. : [];
  8482. });
  8483. /**
  8484. * This method is like `_.intersection` except that it accepts `iteratee`
  8485. * which is invoked for each element of each `arrays` to generate the criterion
  8486. * by which they're compared. The order and references of result values are
  8487. * determined by the first array. The iteratee is invoked with one argument:
  8488. * (value).
  8489. *
  8490. * @static
  8491. * @memberOf _
  8492. * @since 4.0.0
  8493. * @category Array
  8494. * @param {...Array} [arrays] The arrays to inspect.
  8495. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  8496. * @returns {Array} Returns the new array of intersecting values.
  8497. * @example
  8498. *
  8499. * _.intersectionBy([2.1, 1.2], [2.3, 3.4], Math.floor);
  8500. * // => [2.1]
  8501. *
  8502. * // The `_.property` iteratee shorthand.
  8503. * _.intersectionBy([{ 'x': 1 }], [{ 'x': 2 }, { 'x': 1 }], 'x');
  8504. * // => [{ 'x': 1 }]
  8505. */
  8506. var intersectionBy = baseRest(function(arrays) {
  8507. var iteratee = last(arrays),
  8508. mapped = arrayMap(arrays, castArrayLikeObject);
  8509. if (iteratee === last(mapped)) {
  8510. iteratee = undefined;
  8511. } else {
  8512. mapped.pop();
  8513. }
  8514. return (mapped.length && mapped[0] === arrays[0])
  8515. ? baseIntersection(mapped, getIteratee(iteratee, 2))
  8516. : [];
  8517. });
  8518. /**
  8519. * This method is like `_.intersection` except that it accepts `comparator`
  8520. * which is invoked to compare elements of `arrays`. The order and references
  8521. * of result values are determined by the first array. The comparator is
  8522. * invoked with two arguments: (arrVal, othVal).
  8523. *
  8524. * @static
  8525. * @memberOf _
  8526. * @since 4.0.0
  8527. * @category Array
  8528. * @param {...Array} [arrays] The arrays to inspect.
  8529. * @param {Function} [comparator] The comparator invoked per element.
  8530. * @returns {Array} Returns the new array of intersecting values.
  8531. * @example
  8532. *
  8533. * var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }];
  8534. * var others = [{ 'x': 1, 'y': 1 }, { 'x': 1, 'y': 2 }];
  8535. *
  8536. * _.intersectionWith(objects, others, _.isEqual);
  8537. * // => [{ 'x': 1, 'y': 2 }]
  8538. */
  8539. var intersectionWith = baseRest(function(arrays) {
  8540. var comparator = last(arrays),
  8541. mapped = arrayMap(arrays, castArrayLikeObject);
  8542. comparator = typeof comparator == 'function' ? comparator : undefined;
  8543. if (comparator) {
  8544. mapped.pop();
  8545. }
  8546. return (mapped.length && mapped[0] === arrays[0])
  8547. ? baseIntersection(mapped, undefined, comparator)
  8548. : [];
  8549. });
  8550. /**
  8551. * Converts all elements in `array` into a string separated by `separator`.
  8552. *
  8553. * @static
  8554. * @memberOf _
  8555. * @since 4.0.0
  8556. * @category Array
  8557. * @param {Array} array The array to convert.
  8558. * @param {string} [separator=','] The element separator.
  8559. * @returns {string} Returns the joined string.
  8560. * @example
  8561. *
  8562. * _.join(['a', 'b', 'c'], '~');
  8563. * // => 'a~b~c'
  8564. */
  8565. function join(array, separator) {
  8566. return array == null ? '' : nativeJoin.call(array, separator);
  8567. }
  8568. /**
  8569. * Gets the last element of `array`.
  8570. *
  8571. * @static
  8572. * @memberOf _
  8573. * @since 0.1.0
  8574. * @category Array
  8575. * @param {Array} array The array to query.
  8576. * @returns {*} Returns the last element of `array`.
  8577. * @example
  8578. *
  8579. * _.last([1, 2, 3]);
  8580. * // => 3
  8581. */
  8582. function last(array) {
  8583. var length = array == null ? 0 : array.length;
  8584. return length ? array[length - 1] : undefined;
  8585. }
  8586. /**
  8587. * This method is like `_.indexOf` except that it iterates over elements of
  8588. * `array` from right to left.
  8589. *
  8590. * @static
  8591. * @memberOf _
  8592. * @since 0.1.0
  8593. * @category Array
  8594. * @param {Array} array The array to inspect.
  8595. * @param {*} value The value to search for.
  8596. * @param {number} [fromIndex=array.length-1] The index to search from.
  8597. * @returns {number} Returns the index of the matched value, else `-1`.
  8598. * @example
  8599. *
  8600. * _.lastIndexOf([1, 2, 1, 2], 2);
  8601. * // => 3
  8602. *
  8603. * // Search from the `fromIndex`.
  8604. * _.lastIndexOf([1, 2, 1, 2], 2, 2);
  8605. * // => 1
  8606. */
  8607. function lastIndexOf(array, value, fromIndex) {
  8608. var length = array == null ? 0 : array.length;
  8609. if (!length) {
  8610. return -1;
  8611. }
  8612. var index = length;
  8613. if (fromIndex !== undefined) {
  8614. index = toInteger(fromIndex);
  8615. index = index < 0 ? nativeMax(length + index, 0) : nativeMin(index, length - 1);
  8616. }
  8617. return value === value
  8618. ? strictLastIndexOf(array, value, index)
  8619. : baseFindIndex(array, baseIsNaN, index, true);
  8620. }
  8621. /**
  8622. * Gets the element at index `n` of `array`. If `n` is negative, the nth
  8623. * element from the end is returned.
  8624. *
  8625. * @static
  8626. * @memberOf _
  8627. * @since 4.11.0
  8628. * @category Array
  8629. * @param {Array} array The array to query.
  8630. * @param {number} [n=0] The index of the element to return.
  8631. * @returns {*} Returns the nth element of `array`.
  8632. * @example
  8633. *
  8634. * var array = ['a', 'b', 'c', 'd'];
  8635. *
  8636. * _.nth(array, 1);
  8637. * // => 'b'
  8638. *
  8639. * _.nth(array, -2);
  8640. * // => 'c';
  8641. */
  8642. function nth(array, n) {
  8643. return (array && array.length) ? baseNth(array, toInteger(n)) : undefined;
  8644. }
  8645. /**
  8646. * Removes all given values from `array` using
  8647. * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
  8648. * for equality comparisons.
  8649. *
  8650. * **Note:** Unlike `_.without`, this method mutates `array`. Use `_.remove`
  8651. * to remove elements from an array by predicate.
  8652. *
  8653. * @static
  8654. * @memberOf _
  8655. * @since 2.0.0
  8656. * @category Array
  8657. * @param {Array} array The array to modify.
  8658. * @param {...*} [values] The values to remove.
  8659. * @returns {Array} Returns `array`.
  8660. * @example
  8661. *
  8662. * var array = ['a', 'b', 'c', 'a', 'b', 'c'];
  8663. *
  8664. * _.pull(array, 'a', 'c');
  8665. * console.log(array);
  8666. * // => ['b', 'b']
  8667. */
  8668. var pull = baseRest(pullAll);
  8669. /**
  8670. * This method is like `_.pull` except that it accepts an array of values to remove.
  8671. *
  8672. * **Note:** Unlike `_.difference`, this method mutates `array`.
  8673. *
  8674. * @static
  8675. * @memberOf _
  8676. * @since 4.0.0
  8677. * @category Array
  8678. * @param {Array} array The array to modify.
  8679. * @param {Array} values The values to remove.
  8680. * @returns {Array} Returns `array`.
  8681. * @example
  8682. *
  8683. * var array = ['a', 'b', 'c', 'a', 'b', 'c'];
  8684. *
  8685. * _.pullAll(array, ['a', 'c']);
  8686. * console.log(array);
  8687. * // => ['b', 'b']
  8688. */
  8689. function pullAll(array, values) {
  8690. return (array && array.length && values && values.length)
  8691. ? basePullAll(array, values)
  8692. : array;
  8693. }
  8694. /**
  8695. * This method is like `_.pullAll` except that it accepts `iteratee` which is
  8696. * invoked for each element of `array` and `values` to generate the criterion
  8697. * by which they're compared. The iteratee is invoked with one argument: (value).
  8698. *
  8699. * **Note:** Unlike `_.differenceBy`, this method mutates `array`.
  8700. *
  8701. * @static
  8702. * @memberOf _
  8703. * @since 4.0.0
  8704. * @category Array
  8705. * @param {Array} array The array to modify.
  8706. * @param {Array} values The values to remove.
  8707. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  8708. * @returns {Array} Returns `array`.
  8709. * @example
  8710. *
  8711. * var array = [{ 'x': 1 }, { 'x': 2 }, { 'x': 3 }, { 'x': 1 }];
  8712. *
  8713. * _.pullAllBy(array, [{ 'x': 1 }, { 'x': 3 }], 'x');
  8714. * console.log(array);
  8715. * // => [{ 'x': 2 }]
  8716. */
  8717. function pullAllBy(array, values, iteratee) {
  8718. return (array && array.length && values && values.length)
  8719. ? basePullAll(array, values, getIteratee(iteratee, 2))
  8720. : array;
  8721. }
  8722. /**
  8723. * This method is like `_.pullAll` except that it accepts `comparator` which
  8724. * is invoked to compare elements of `array` to `values`. The comparator is
  8725. * invoked with two arguments: (arrVal, othVal).
  8726. *
  8727. * **Note:** Unlike `_.differenceWith`, this method mutates `array`.
  8728. *
  8729. * @static
  8730. * @memberOf _
  8731. * @since 4.6.0
  8732. * @category Array
  8733. * @param {Array} array The array to modify.
  8734. * @param {Array} values The values to remove.
  8735. * @param {Function} [comparator] The comparator invoked per element.
  8736. * @returns {Array} Returns `array`.
  8737. * @example
  8738. *
  8739. * var array = [{ 'x': 1, 'y': 2 }, { 'x': 3, 'y': 4 }, { 'x': 5, 'y': 6 }];
  8740. *
  8741. * _.pullAllWith(array, [{ 'x': 3, 'y': 4 }], _.isEqual);
  8742. * console.log(array);
  8743. * // => [{ 'x': 1, 'y': 2 }, { 'x': 5, 'y': 6 }]
  8744. */
  8745. function pullAllWith(array, values, comparator) {
  8746. return (array && array.length && values && values.length)
  8747. ? basePullAll(array, values, undefined, comparator)
  8748. : array;
  8749. }
  8750. /**
  8751. * Removes elements from `array` corresponding to `indexes` and returns an
  8752. * array of removed elements.
  8753. *
  8754. * **Note:** Unlike `_.at`, this method mutates `array`.
  8755. *
  8756. * @static
  8757. * @memberOf _
  8758. * @since 3.0.0
  8759. * @category Array
  8760. * @param {Array} array The array to modify.
  8761. * @param {...(number|number[])} [indexes] The indexes of elements to remove.
  8762. * @returns {Array} Returns the new array of removed elements.
  8763. * @example
  8764. *
  8765. * var array = ['a', 'b', 'c', 'd'];
  8766. * var pulled = _.pullAt(array, [1, 3]);
  8767. *
  8768. * console.log(array);
  8769. * // => ['a', 'c']
  8770. *
  8771. * console.log(pulled);
  8772. * // => ['b', 'd']
  8773. */
  8774. var pullAt = flatRest(function(array, indexes) {
  8775. var length = array == null ? 0 : array.length,
  8776. result = baseAt(array, indexes);
  8777. basePullAt(array, arrayMap(indexes, function(index) {
  8778. return isIndex(index, length) ? +index : index;
  8779. }).sort(compareAscending));
  8780. return result;
  8781. });
  8782. /**
  8783. * Removes all elements from `array` that `predicate` returns truthy for
  8784. * and returns an array of the removed elements. The predicate is invoked
  8785. * with three arguments: (value, index, array).
  8786. *
  8787. * **Note:** Unlike `_.filter`, this method mutates `array`. Use `_.pull`
  8788. * to pull elements from an array by value.
  8789. *
  8790. * @static
  8791. * @memberOf _
  8792. * @since 2.0.0
  8793. * @category Array
  8794. * @param {Array} array The array to modify.
  8795. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  8796. * @returns {Array} Returns the new array of removed elements.
  8797. * @example
  8798. *
  8799. * var array = [1, 2, 3, 4];
  8800. * var evens = _.remove(array, function(n) {
  8801. * return n % 2 == 0;
  8802. * });
  8803. *
  8804. * console.log(array);
  8805. * // => [1, 3]
  8806. *
  8807. * console.log(evens);
  8808. * // => [2, 4]
  8809. */
  8810. function remove(array, predicate) {
  8811. var result = [];
  8812. if (!(array && array.length)) {
  8813. return result;
  8814. }
  8815. var index = -1,
  8816. indexes = [],
  8817. length = array.length;
  8818. predicate = getIteratee(predicate, 3);
  8819. while (++index < length) {
  8820. var value = array[index];
  8821. if (predicate(value, index, array)) {
  8822. result.push(value);
  8823. indexes.push(index);
  8824. }
  8825. }
  8826. basePullAt(array, indexes);
  8827. return result;
  8828. }
  8829. /**
  8830. * Reverses `array` so that the first element becomes the last, the second
  8831. * element becomes the second to last, and so on.
  8832. *
  8833. * **Note:** This method mutates `array` and is based on
  8834. * [`Array#reverse`](https://mdn.io/Array/reverse).
  8835. *
  8836. * @static
  8837. * @memberOf _
  8838. * @since 4.0.0
  8839. * @category Array
  8840. * @param {Array} array The array to modify.
  8841. * @returns {Array} Returns `array`.
  8842. * @example
  8843. *
  8844. * var array = [1, 2, 3];
  8845. *
  8846. * _.reverse(array);
  8847. * // => [3, 2, 1]
  8848. *
  8849. * console.log(array);
  8850. * // => [3, 2, 1]
  8851. */
  8852. function reverse(array) {
  8853. return array == null ? array : nativeReverse.call(array);
  8854. }
  8855. /**
  8856. * Creates a slice of `array` from `start` up to, but not including, `end`.
  8857. *
  8858. * **Note:** This method is used instead of
  8859. * [`Array#slice`](https://mdn.io/Array/slice) to ensure dense arrays are
  8860. * returned.
  8861. *
  8862. * @static
  8863. * @memberOf _
  8864. * @since 3.0.0
  8865. * @category Array
  8866. * @param {Array} array The array to slice.
  8867. * @param {number} [start=0] The start position.
  8868. * @param {number} [end=array.length] The end position.
  8869. * @returns {Array} Returns the slice of `array`.
  8870. */
  8871. function slice(array, start, end) {
  8872. var length = array == null ? 0 : array.length;
  8873. if (!length) {
  8874. return [];
  8875. }
  8876. if (end && typeof end != 'number' && isIterateeCall(array, start, end)) {
  8877. start = 0;
  8878. end = length;
  8879. }
  8880. else {
  8881. start = start == null ? 0 : toInteger(start);
  8882. end = end === undefined ? length : toInteger(end);
  8883. }
  8884. return baseSlice(array, start, end);
  8885. }
  8886. /**
  8887. * Uses a binary search to determine the lowest index at which `value`
  8888. * should be inserted into `array` in order to maintain its sort order.
  8889. *
  8890. * @static
  8891. * @memberOf _
  8892. * @since 0.1.0
  8893. * @category Array
  8894. * @param {Array} array The sorted array to inspect.
  8895. * @param {*} value The value to evaluate.
  8896. * @returns {number} Returns the index at which `value` should be inserted
  8897. * into `array`.
  8898. * @example
  8899. *
  8900. * _.sortedIndex([30, 50], 40);
  8901. * // => 1
  8902. */
  8903. function sortedIndex(array, value) {
  8904. return baseSortedIndex(array, value);
  8905. }
  8906. /**
  8907. * This method is like `_.sortedIndex` except that it accepts `iteratee`
  8908. * which is invoked for `value` and each element of `array` to compute their
  8909. * sort ranking. The iteratee is invoked with one argument: (value).
  8910. *
  8911. * @static
  8912. * @memberOf _
  8913. * @since 4.0.0
  8914. * @category Array
  8915. * @param {Array} array The sorted array to inspect.
  8916. * @param {*} value The value to evaluate.
  8917. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  8918. * @returns {number} Returns the index at which `value` should be inserted
  8919. * into `array`.
  8920. * @example
  8921. *
  8922. * var objects = [{ 'x': 4 }, { 'x': 5 }];
  8923. *
  8924. * _.sortedIndexBy(objects, { 'x': 4 }, function(o) { return o.x; });
  8925. * // => 0
  8926. *
  8927. * // The `_.property` iteratee shorthand.
  8928. * _.sortedIndexBy(objects, { 'x': 4 }, 'x');
  8929. * // => 0
  8930. */
  8931. function sortedIndexBy(array, value, iteratee) {
  8932. return baseSortedIndexBy(array, value, getIteratee(iteratee, 2));
  8933. }
  8934. /**
  8935. * This method is like `_.indexOf` except that it performs a binary
  8936. * search on a sorted `array`.
  8937. *
  8938. * @static
  8939. * @memberOf _
  8940. * @since 4.0.0
  8941. * @category Array
  8942. * @param {Array} array The array to inspect.
  8943. * @param {*} value The value to search for.
  8944. * @returns {number} Returns the index of the matched value, else `-1`.
  8945. * @example
  8946. *
  8947. * _.sortedIndexOf([4, 5, 5, 5, 6], 5);
  8948. * // => 1
  8949. */
  8950. function sortedIndexOf(array, value) {
  8951. var length = array == null ? 0 : array.length;
  8952. if (length) {
  8953. var index = baseSortedIndex(array, value);
  8954. if (index < length && eq(array[index], value)) {
  8955. return index;
  8956. }
  8957. }
  8958. return -1;
  8959. }
  8960. /**
  8961. * This method is like `_.sortedIndex` except that it returns the highest
  8962. * index at which `value` should be inserted into `array` in order to
  8963. * maintain its sort order.
  8964. *
  8965. * @static
  8966. * @memberOf _
  8967. * @since 3.0.0
  8968. * @category Array
  8969. * @param {Array} array The sorted array to inspect.
  8970. * @param {*} value The value to evaluate.
  8971. * @returns {number} Returns the index at which `value` should be inserted
  8972. * into `array`.
  8973. * @example
  8974. *
  8975. * _.sortedLastIndex([4, 5, 5, 5, 6], 5);
  8976. * // => 4
  8977. */
  8978. function sortedLastIndex(array, value) {
  8979. return baseSortedIndex(array, value, true);
  8980. }
  8981. /**
  8982. * This method is like `_.sortedLastIndex` except that it accepts `iteratee`
  8983. * which is invoked for `value` and each element of `array` to compute their
  8984. * sort ranking. The iteratee is invoked with one argument: (value).
  8985. *
  8986. * @static
  8987. * @memberOf _
  8988. * @since 4.0.0
  8989. * @category Array
  8990. * @param {Array} array The sorted array to inspect.
  8991. * @param {*} value The value to evaluate.
  8992. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  8993. * @returns {number} Returns the index at which `value` should be inserted
  8994. * into `array`.
  8995. * @example
  8996. *
  8997. * var objects = [{ 'x': 4 }, { 'x': 5 }];
  8998. *
  8999. * _.sortedLastIndexBy(objects, { 'x': 4 }, function(o) { return o.x; });
  9000. * // => 1
  9001. *
  9002. * // The `_.property` iteratee shorthand.
  9003. * _.sortedLastIndexBy(objects, { 'x': 4 }, 'x');
  9004. * // => 1
  9005. */
  9006. function sortedLastIndexBy(array, value, iteratee) {
  9007. return baseSortedIndexBy(array, value, getIteratee(iteratee, 2), true);
  9008. }
  9009. /**
  9010. * This method is like `_.lastIndexOf` except that it performs a binary
  9011. * search on a sorted `array`.
  9012. *
  9013. * @static
  9014. * @memberOf _
  9015. * @since 4.0.0
  9016. * @category Array
  9017. * @param {Array} array The array to inspect.
  9018. * @param {*} value The value to search for.
  9019. * @returns {number} Returns the index of the matched value, else `-1`.
  9020. * @example
  9021. *
  9022. * _.sortedLastIndexOf([4, 5, 5, 5, 6], 5);
  9023. * // => 3
  9024. */
  9025. function sortedLastIndexOf(array, value) {
  9026. var length = array == null ? 0 : array.length;
  9027. if (length) {
  9028. var index = baseSortedIndex(array, value, true) - 1;
  9029. if (eq(array[index], value)) {
  9030. return index;
  9031. }
  9032. }
  9033. return -1;
  9034. }
  9035. /**
  9036. * This method is like `_.uniq` except that it's designed and optimized
  9037. * for sorted arrays.
  9038. *
  9039. * @static
  9040. * @memberOf _
  9041. * @since 4.0.0
  9042. * @category Array
  9043. * @param {Array} array The array to inspect.
  9044. * @returns {Array} Returns the new duplicate free array.
  9045. * @example
  9046. *
  9047. * _.sortedUniq([1, 1, 2]);
  9048. * // => [1, 2]
  9049. */
  9050. function sortedUniq(array) {
  9051. return (array && array.length)
  9052. ? baseSortedUniq(array)
  9053. : [];
  9054. }
  9055. /**
  9056. * This method is like `_.uniqBy` except that it's designed and optimized
  9057. * for sorted arrays.
  9058. *
  9059. * @static
  9060. * @memberOf _
  9061. * @since 4.0.0
  9062. * @category Array
  9063. * @param {Array} array The array to inspect.
  9064. * @param {Function} [iteratee] The iteratee invoked per element.
  9065. * @returns {Array} Returns the new duplicate free array.
  9066. * @example
  9067. *
  9068. * _.sortedUniqBy([1.1, 1.2, 2.3, 2.4], Math.floor);
  9069. * // => [1.1, 2.3]
  9070. */
  9071. function sortedUniqBy(array, iteratee) {
  9072. return (array && array.length)
  9073. ? baseSortedUniq(array, getIteratee(iteratee, 2))
  9074. : [];
  9075. }
  9076. /**
  9077. * Gets all but the first element of `array`.
  9078. *
  9079. * @static
  9080. * @memberOf _
  9081. * @since 4.0.0
  9082. * @category Array
  9083. * @param {Array} array The array to query.
  9084. * @returns {Array} Returns the slice of `array`.
  9085. * @example
  9086. *
  9087. * _.tail([1, 2, 3]);
  9088. * // => [2, 3]
  9089. */
  9090. function tail(array) {
  9091. var length = array == null ? 0 : array.length;
  9092. return length ? baseSlice(array, 1, length) : [];
  9093. }
  9094. /**
  9095. * Creates a slice of `array` with `n` elements taken from the beginning.
  9096. *
  9097. * @static
  9098. * @memberOf _
  9099. * @since 0.1.0
  9100. * @category Array
  9101. * @param {Array} array The array to query.
  9102. * @param {number} [n=1] The number of elements to take.
  9103. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  9104. * @returns {Array} Returns the slice of `array`.
  9105. * @example
  9106. *
  9107. * _.take([1, 2, 3]);
  9108. * // => [1]
  9109. *
  9110. * _.take([1, 2, 3], 2);
  9111. * // => [1, 2]
  9112. *
  9113. * _.take([1, 2, 3], 5);
  9114. * // => [1, 2, 3]
  9115. *
  9116. * _.take([1, 2, 3], 0);
  9117. * // => []
  9118. */
  9119. function take(array, n, guard) {
  9120. if (!(array && array.length)) {
  9121. return [];
  9122. }
  9123. n = (guard || n === undefined) ? 1 : toInteger(n);
  9124. return baseSlice(array, 0, n < 0 ? 0 : n);
  9125. }
  9126. /**
  9127. * Creates a slice of `array` with `n` elements taken from the end.
  9128. *
  9129. * @static
  9130. * @memberOf _
  9131. * @since 3.0.0
  9132. * @category Array
  9133. * @param {Array} array The array to query.
  9134. * @param {number} [n=1] The number of elements to take.
  9135. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  9136. * @returns {Array} Returns the slice of `array`.
  9137. * @example
  9138. *
  9139. * _.takeRight([1, 2, 3]);
  9140. * // => [3]
  9141. *
  9142. * _.takeRight([1, 2, 3], 2);
  9143. * // => [2, 3]
  9144. *
  9145. * _.takeRight([1, 2, 3], 5);
  9146. * // => [1, 2, 3]
  9147. *
  9148. * _.takeRight([1, 2, 3], 0);
  9149. * // => []
  9150. */
  9151. function takeRight(array, n, guard) {
  9152. var length = array == null ? 0 : array.length;
  9153. if (!length) {
  9154. return [];
  9155. }
  9156. n = (guard || n === undefined) ? 1 : toInteger(n);
  9157. n = length - n;
  9158. return baseSlice(array, n < 0 ? 0 : n, length);
  9159. }
  9160. /**
  9161. * Creates a slice of `array` with elements taken from the end. Elements are
  9162. * taken until `predicate` returns falsey. The predicate is invoked with
  9163. * three arguments: (value, index, array).
  9164. *
  9165. * @static
  9166. * @memberOf _
  9167. * @since 3.0.0
  9168. * @category Array
  9169. * @param {Array} array The array to query.
  9170. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  9171. * @returns {Array} Returns the slice of `array`.
  9172. * @example
  9173. *
  9174. * var users = [
  9175. * { 'user': 'barney', 'active': true },
  9176. * { 'user': 'fred', 'active': false },
  9177. * { 'user': 'pebbles', 'active': false }
  9178. * ];
  9179. *
  9180. * _.takeRightWhile(users, function(o) { return !o.active; });
  9181. * // => objects for ['fred', 'pebbles']
  9182. *
  9183. * // The `_.matches` iteratee shorthand.
  9184. * _.takeRightWhile(users, { 'user': 'pebbles', 'active': false });
  9185. * // => objects for ['pebbles']
  9186. *
  9187. * // The `_.matchesProperty` iteratee shorthand.
  9188. * _.takeRightWhile(users, ['active', false]);
  9189. * // => objects for ['fred', 'pebbles']
  9190. *
  9191. * // The `_.property` iteratee shorthand.
  9192. * _.takeRightWhile(users, 'active');
  9193. * // => []
  9194. */
  9195. function takeRightWhile(array, predicate) {
  9196. return (array && array.length)
  9197. ? baseWhile(array, getIteratee(predicate, 3), false, true)
  9198. : [];
  9199. }
  9200. /**
  9201. * Creates a slice of `array` with elements taken from the beginning. Elements
  9202. * are taken until `predicate` returns falsey. The predicate is invoked with
  9203. * three arguments: (value, index, array).
  9204. *
  9205. * @static
  9206. * @memberOf _
  9207. * @since 3.0.0
  9208. * @category Array
  9209. * @param {Array} array The array to query.
  9210. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  9211. * @returns {Array} Returns the slice of `array`.
  9212. * @example
  9213. *
  9214. * var users = [
  9215. * { 'user': 'barney', 'active': false },
  9216. * { 'user': 'fred', 'active': false },
  9217. * { 'user': 'pebbles', 'active': true }
  9218. * ];
  9219. *
  9220. * _.takeWhile(users, function(o) { return !o.active; });
  9221. * // => objects for ['barney', 'fred']
  9222. *
  9223. * // The `_.matches` iteratee shorthand.
  9224. * _.takeWhile(users, { 'user': 'barney', 'active': false });
  9225. * // => objects for ['barney']
  9226. *
  9227. * // The `_.matchesProperty` iteratee shorthand.
  9228. * _.takeWhile(users, ['active', false]);
  9229. * // => objects for ['barney', 'fred']
  9230. *
  9231. * // The `_.property` iteratee shorthand.
  9232. * _.takeWhile(users, 'active');
  9233. * // => []
  9234. */
  9235. function takeWhile(array, predicate) {
  9236. return (array && array.length)
  9237. ? baseWhile(array, getIteratee(predicate, 3))
  9238. : [];
  9239. }
  9240. /**
  9241. * Creates an array of unique values, in order, from all given arrays using
  9242. * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
  9243. * for equality comparisons.
  9244. *
  9245. * @static
  9246. * @memberOf _
  9247. * @since 0.1.0
  9248. * @category Array
  9249. * @param {...Array} [arrays] The arrays to inspect.
  9250. * @returns {Array} Returns the new array of combined values.
  9251. * @example
  9252. *
  9253. * _.union([2], [1, 2]);
  9254. * // => [2, 1]
  9255. */
  9256. var union = baseRest(function(arrays) {
  9257. return baseUniq(baseFlatten(arrays, 1, isArrayLikeObject, true));
  9258. });
  9259. /**
  9260. * This method is like `_.union` except that it accepts `iteratee` which is
  9261. * invoked for each element of each `arrays` to generate the criterion by
  9262. * which uniqueness is computed. Result values are chosen from the first
  9263. * array in which the value occurs. The iteratee is invoked with one argument:
  9264. * (value).
  9265. *
  9266. * @static
  9267. * @memberOf _
  9268. * @since 4.0.0
  9269. * @category Array
  9270. * @param {...Array} [arrays] The arrays to inspect.
  9271. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  9272. * @returns {Array} Returns the new array of combined values.
  9273. * @example
  9274. *
  9275. * _.unionBy([2.1], [1.2, 2.3], Math.floor);
  9276. * // => [2.1, 1.2]
  9277. *
  9278. * // The `_.property` iteratee shorthand.
  9279. * _.unionBy([{ 'x': 1 }], [{ 'x': 2 }, { 'x': 1 }], 'x');
  9280. * // => [{ 'x': 1 }, { 'x': 2 }]
  9281. */
  9282. var unionBy = baseRest(function(arrays) {
  9283. var iteratee = last(arrays);
  9284. if (isArrayLikeObject(iteratee)) {
  9285. iteratee = undefined;
  9286. }
  9287. return baseUniq(baseFlatten(arrays, 1, isArrayLikeObject, true), getIteratee(iteratee, 2));
  9288. });
  9289. /**
  9290. * This method is like `_.union` except that it accepts `comparator` which
  9291. * is invoked to compare elements of `arrays`. Result values are chosen from
  9292. * the first array in which the value occurs. The comparator is invoked
  9293. * with two arguments: (arrVal, othVal).
  9294. *
  9295. * @static
  9296. * @memberOf _
  9297. * @since 4.0.0
  9298. * @category Array
  9299. * @param {...Array} [arrays] The arrays to inspect.
  9300. * @param {Function} [comparator] The comparator invoked per element.
  9301. * @returns {Array} Returns the new array of combined values.
  9302. * @example
  9303. *
  9304. * var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }];
  9305. * var others = [{ 'x': 1, 'y': 1 }, { 'x': 1, 'y': 2 }];
  9306. *
  9307. * _.unionWith(objects, others, _.isEqual);
  9308. * // => [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }, { 'x': 1, 'y': 1 }]
  9309. */
  9310. var unionWith = baseRest(function(arrays) {
  9311. var comparator = last(arrays);
  9312. comparator = typeof comparator == 'function' ? comparator : undefined;
  9313. return baseUniq(baseFlatten(arrays, 1, isArrayLikeObject, true), undefined, comparator);
  9314. });
  9315. /**
  9316. * Creates a duplicate-free version of an array, using
  9317. * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
  9318. * for equality comparisons, in which only the first occurrence of each element
  9319. * is kept. The order of result values is determined by the order they occur
  9320. * in the array.
  9321. *
  9322. * @static
  9323. * @memberOf _
  9324. * @since 0.1.0
  9325. * @category Array
  9326. * @param {Array} array The array to inspect.
  9327. * @returns {Array} Returns the new duplicate free array.
  9328. * @example
  9329. *
  9330. * _.uniq([2, 1, 2]);
  9331. * // => [2, 1]
  9332. */
  9333. function uniq(array) {
  9334. return (array && array.length) ? baseUniq(array) : [];
  9335. }
  9336. /**
  9337. * This method is like `_.uniq` except that it accepts `iteratee` which is
  9338. * invoked for each element in `array` to generate the criterion by which
  9339. * uniqueness is computed. The order of result values is determined by the
  9340. * order they occur in the array. The iteratee is invoked with one argument:
  9341. * (value).
  9342. *
  9343. * @static
  9344. * @memberOf _
  9345. * @since 4.0.0
  9346. * @category Array
  9347. * @param {Array} array The array to inspect.
  9348. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  9349. * @returns {Array} Returns the new duplicate free array.
  9350. * @example
  9351. *
  9352. * _.uniqBy([2.1, 1.2, 2.3], Math.floor);
  9353. * // => [2.1, 1.2]
  9354. *
  9355. * // The `_.property` iteratee shorthand.
  9356. * _.uniqBy([{ 'x': 1 }, { 'x': 2 }, { 'x': 1 }], 'x');
  9357. * // => [{ 'x': 1 }, { 'x': 2 }]
  9358. */
  9359. function uniqBy(array, iteratee) {
  9360. return (array && array.length) ? baseUniq(array, getIteratee(iteratee, 2)) : [];
  9361. }
  9362. /**
  9363. * This method is like `_.uniq` except that it accepts `comparator` which
  9364. * is invoked to compare elements of `array`. The order of result values is
  9365. * determined by the order they occur in the array.The comparator is invoked
  9366. * with two arguments: (arrVal, othVal).
  9367. *
  9368. * @static
  9369. * @memberOf _
  9370. * @since 4.0.0
  9371. * @category Array
  9372. * @param {Array} array The array to inspect.
  9373. * @param {Function} [comparator] The comparator invoked per element.
  9374. * @returns {Array} Returns the new duplicate free array.
  9375. * @example
  9376. *
  9377. * var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }, { 'x': 1, 'y': 2 }];
  9378. *
  9379. * _.uniqWith(objects, _.isEqual);
  9380. * // => [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }]
  9381. */
  9382. function uniqWith(array, comparator) {
  9383. comparator = typeof comparator == 'function' ? comparator : undefined;
  9384. return (array && array.length) ? baseUniq(array, undefined, comparator) : [];
  9385. }
  9386. /**
  9387. * This method is like `_.zip` except that it accepts an array of grouped
  9388. * elements and creates an array regrouping the elements to their pre-zip
  9389. * configuration.
  9390. *
  9391. * @static
  9392. * @memberOf _
  9393. * @since 1.2.0
  9394. * @category Array
  9395. * @param {Array} array The array of grouped elements to process.
  9396. * @returns {Array} Returns the new array of regrouped elements.
  9397. * @example
  9398. *
  9399. * var zipped = _.zip(['a', 'b'], [1, 2], [true, false]);
  9400. * // => [['a', 1, true], ['b', 2, false]]
  9401. *
  9402. * _.unzip(zipped);
  9403. * // => [['a', 'b'], [1, 2], [true, false]]
  9404. */
  9405. function unzip(array) {
  9406. if (!(array && array.length)) {
  9407. return [];
  9408. }
  9409. var length = 0;
  9410. array = arrayFilter(array, function(group) {
  9411. if (isArrayLikeObject(group)) {
  9412. length = nativeMax(group.length, length);
  9413. return true;
  9414. }
  9415. });
  9416. return baseTimes(length, function(index) {
  9417. return arrayMap(array, baseProperty(index));
  9418. });
  9419. }
  9420. /**
  9421. * This method is like `_.unzip` except that it accepts `iteratee` to specify
  9422. * how regrouped values should be combined. The iteratee is invoked with the
  9423. * elements of each group: (...group).
  9424. *
  9425. * @static
  9426. * @memberOf _
  9427. * @since 3.8.0
  9428. * @category Array
  9429. * @param {Array} array The array of grouped elements to process.
  9430. * @param {Function} [iteratee=_.identity] The function to combine
  9431. * regrouped values.
  9432. * @returns {Array} Returns the new array of regrouped elements.
  9433. * @example
  9434. *
  9435. * var zipped = _.zip([1, 2], [10, 20], [100, 200]);
  9436. * // => [[1, 10, 100], [2, 20, 200]]
  9437. *
  9438. * _.unzipWith(zipped, _.add);
  9439. * // => [3, 30, 300]
  9440. */
  9441. function unzipWith(array, iteratee) {
  9442. if (!(array && array.length)) {
  9443. return [];
  9444. }
  9445. var result = unzip(array);
  9446. if (iteratee == null) {
  9447. return result;
  9448. }
  9449. return arrayMap(result, function(group) {
  9450. return apply(iteratee, undefined, group);
  9451. });
  9452. }
  9453. /**
  9454. * Creates an array excluding all given values using
  9455. * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
  9456. * for equality comparisons.
  9457. *
  9458. * **Note:** Unlike `_.pull`, this method returns a new array.
  9459. *
  9460. * @static
  9461. * @memberOf _
  9462. * @since 0.1.0
  9463. * @category Array
  9464. * @param {Array} array The array to inspect.
  9465. * @param {...*} [values] The values to exclude.
  9466. * @returns {Array} Returns the new array of filtered values.
  9467. * @see _.difference, _.xor
  9468. * @example
  9469. *
  9470. * _.without([2, 1, 2, 3], 1, 2);
  9471. * // => [3]
  9472. */
  9473. var without = baseRest(function(array, values) {
  9474. return isArrayLikeObject(array)
  9475. ? baseDifference(array, values)
  9476. : [];
  9477. });
  9478. /**
  9479. * Creates an array of unique values that is the
  9480. * [symmetric difference](https://en.wikipedia.org/wiki/Symmetric_difference)
  9481. * of the given arrays. The order of result values is determined by the order
  9482. * they occur in the arrays.
  9483. *
  9484. * @static
  9485. * @memberOf _
  9486. * @since 2.4.0
  9487. * @category Array
  9488. * @param {...Array} [arrays] The arrays to inspect.
  9489. * @returns {Array} Returns the new array of filtered values.
  9490. * @see _.difference, _.without
  9491. * @example
  9492. *
  9493. * _.xor([2, 1], [2, 3]);
  9494. * // => [1, 3]
  9495. */
  9496. var xor = baseRest(function(arrays) {
  9497. return baseXor(arrayFilter(arrays, isArrayLikeObject));
  9498. });
  9499. /**
  9500. * This method is like `_.xor` except that it accepts `iteratee` which is
  9501. * invoked for each element of each `arrays` to generate the criterion by
  9502. * which by which they're compared. The order of result values is determined
  9503. * by the order they occur in the arrays. The iteratee is invoked with one
  9504. * argument: (value).
  9505. *
  9506. * @static
  9507. * @memberOf _
  9508. * @since 4.0.0
  9509. * @category Array
  9510. * @param {...Array} [arrays] The arrays to inspect.
  9511. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  9512. * @returns {Array} Returns the new array of filtered values.
  9513. * @example
  9514. *
  9515. * _.xorBy([2.1, 1.2], [2.3, 3.4], Math.floor);
  9516. * // => [1.2, 3.4]
  9517. *
  9518. * // The `_.property` iteratee shorthand.
  9519. * _.xorBy([{ 'x': 1 }], [{ 'x': 2 }, { 'x': 1 }], 'x');
  9520. * // => [{ 'x': 2 }]
  9521. */
  9522. var xorBy = baseRest(function(arrays) {
  9523. var iteratee = last(arrays);
  9524. if (isArrayLikeObject(iteratee)) {
  9525. iteratee = undefined;
  9526. }
  9527. return baseXor(arrayFilter(arrays, isArrayLikeObject), getIteratee(iteratee, 2));
  9528. });
  9529. /**
  9530. * This method is like `_.xor` except that it accepts `comparator` which is
  9531. * invoked to compare elements of `arrays`. The order of result values is
  9532. * determined by the order they occur in the arrays. The comparator is invoked
  9533. * with two arguments: (arrVal, othVal).
  9534. *
  9535. * @static
  9536. * @memberOf _
  9537. * @since 4.0.0
  9538. * @category Array
  9539. * @param {...Array} [arrays] The arrays to inspect.
  9540. * @param {Function} [comparator] The comparator invoked per element.
  9541. * @returns {Array} Returns the new array of filtered values.
  9542. * @example
  9543. *
  9544. * var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }];
  9545. * var others = [{ 'x': 1, 'y': 1 }, { 'x': 1, 'y': 2 }];
  9546. *
  9547. * _.xorWith(objects, others, _.isEqual);
  9548. * // => [{ 'x': 2, 'y': 1 }, { 'x': 1, 'y': 1 }]
  9549. */
  9550. var xorWith = baseRest(function(arrays) {
  9551. var comparator = last(arrays);
  9552. comparator = typeof comparator == 'function' ? comparator : undefined;
  9553. return baseXor(arrayFilter(arrays, isArrayLikeObject), undefined, comparator);
  9554. });
  9555. /**
  9556. * Creates an array of grouped elements, the first of which contains the
  9557. * first elements of the given arrays, the second of which contains the
  9558. * second elements of the given arrays, and so on.
  9559. *
  9560. * @static
  9561. * @memberOf _
  9562. * @since 0.1.0
  9563. * @category Array
  9564. * @param {...Array} [arrays] The arrays to process.
  9565. * @returns {Array} Returns the new array of grouped elements.
  9566. * @example
  9567. *
  9568. * _.zip(['a', 'b'], [1, 2], [true, false]);
  9569. * // => [['a', 1, true], ['b', 2, false]]
  9570. */
  9571. var zip = baseRest(unzip);
  9572. /**
  9573. * This method is like `_.fromPairs` except that it accepts two arrays,
  9574. * one of property identifiers and one of corresponding values.
  9575. *
  9576. * @static
  9577. * @memberOf _
  9578. * @since 0.4.0
  9579. * @category Array
  9580. * @param {Array} [props=[]] The property identifiers.
  9581. * @param {Array} [values=[]] The property values.
  9582. * @returns {Object} Returns the new object.
  9583. * @example
  9584. *
  9585. * _.zipObject(['a', 'b'], [1, 2]);
  9586. * // => { 'a': 1, 'b': 2 }
  9587. */
  9588. function zipObject(props, values) {
  9589. return baseZipObject(props || [], values || [], assignValue);
  9590. }
  9591. /**
  9592. * This method is like `_.zipObject` except that it supports property paths.
  9593. *
  9594. * @static
  9595. * @memberOf _
  9596. * @since 4.1.0
  9597. * @category Array
  9598. * @param {Array} [props=[]] The property identifiers.
  9599. * @param {Array} [values=[]] The property values.
  9600. * @returns {Object} Returns the new object.
  9601. * @example
  9602. *
  9603. * _.zipObjectDeep(['a.b[0].c', 'a.b[1].d'], [1, 2]);
  9604. * // => { 'a': { 'b': [{ 'c': 1 }, { 'd': 2 }] } }
  9605. */
  9606. function zipObjectDeep(props, values) {
  9607. return baseZipObject(props || [], values || [], baseSet);
  9608. }
  9609. /**
  9610. * This method is like `_.zip` except that it accepts `iteratee` to specify
  9611. * how grouped values should be combined. The iteratee is invoked with the
  9612. * elements of each group: (...group).
  9613. *
  9614. * @static
  9615. * @memberOf _
  9616. * @since 3.8.0
  9617. * @category Array
  9618. * @param {...Array} [arrays] The arrays to process.
  9619. * @param {Function} [iteratee=_.identity] The function to combine
  9620. * grouped values.
  9621. * @returns {Array} Returns the new array of grouped elements.
  9622. * @example
  9623. *
  9624. * _.zipWith([1, 2], [10, 20], [100, 200], function(a, b, c) {
  9625. * return a + b + c;
  9626. * });
  9627. * // => [111, 222]
  9628. */
  9629. var zipWith = baseRest(function(arrays) {
  9630. var length = arrays.length,
  9631. iteratee = length > 1 ? arrays[length - 1] : undefined;
  9632. iteratee = typeof iteratee == 'function' ? (arrays.pop(), iteratee) : undefined;
  9633. return unzipWith(arrays, iteratee);
  9634. });
  9635. /*------------------------------------------------------------------------*/
  9636. /**
  9637. * Creates a `lodash` wrapper instance that wraps `value` with explicit method
  9638. * chain sequences enabled. The result of such sequences must be unwrapped
  9639. * with `_#value`.
  9640. *
  9641. * @static
  9642. * @memberOf _
  9643. * @since 1.3.0
  9644. * @category Seq
  9645. * @param {*} value The value to wrap.
  9646. * @returns {Object} Returns the new `lodash` wrapper instance.
  9647. * @example
  9648. *
  9649. * var users = [
  9650. * { 'user': 'barney', 'age': 36 },
  9651. * { 'user': 'fred', 'age': 40 },
  9652. * { 'user': 'pebbles', 'age': 1 }
  9653. * ];
  9654. *
  9655. * var youngest = _
  9656. * .chain(users)
  9657. * .sortBy('age')
  9658. * .map(function(o) {
  9659. * return o.user + ' is ' + o.age;
  9660. * })
  9661. * .head()
  9662. * .value();
  9663. * // => 'pebbles is 1'
  9664. */
  9665. function chain(value) {
  9666. var result = lodash(value);
  9667. result.__chain__ = true;
  9668. return result;
  9669. }
  9670. /**
  9671. * This method invokes `interceptor` and returns `value`. The interceptor
  9672. * is invoked with one argument; (value). The purpose of this method is to
  9673. * "tap into" a method chain sequence in order to modify intermediate results.
  9674. *
  9675. * @static
  9676. * @memberOf _
  9677. * @since 0.1.0
  9678. * @category Seq
  9679. * @param {*} value The value to provide to `interceptor`.
  9680. * @param {Function} interceptor The function to invoke.
  9681. * @returns {*} Returns `value`.
  9682. * @example
  9683. *
  9684. * _([1, 2, 3])
  9685. * .tap(function(array) {
  9686. * // Mutate input array.
  9687. * array.pop();
  9688. * })
  9689. * .reverse()
  9690. * .value();
  9691. * // => [2, 1]
  9692. */
  9693. function tap(value, interceptor) {
  9694. interceptor(value);
  9695. return value;
  9696. }
  9697. /**
  9698. * This method is like `_.tap` except that it returns the result of `interceptor`.
  9699. * The purpose of this method is to "pass thru" values replacing intermediate
  9700. * results in a method chain sequence.
  9701. *
  9702. * @static
  9703. * @memberOf _
  9704. * @since 3.0.0
  9705. * @category Seq
  9706. * @param {*} value The value to provide to `interceptor`.
  9707. * @param {Function} interceptor The function to invoke.
  9708. * @returns {*} Returns the result of `interceptor`.
  9709. * @example
  9710. *
  9711. * _(' abc ')
  9712. * .chain()
  9713. * .trim()
  9714. * .thru(function(value) {
  9715. * return [value];
  9716. * })
  9717. * .value();
  9718. * // => ['abc']
  9719. */
  9720. function thru(value, interceptor) {
  9721. return interceptor(value);
  9722. }
  9723. /**
  9724. * This method is the wrapper version of `_.at`.
  9725. *
  9726. * @name at
  9727. * @memberOf _
  9728. * @since 1.0.0
  9729. * @category Seq
  9730. * @param {...(string|string[])} [paths] The property paths to pick.
  9731. * @returns {Object} Returns the new `lodash` wrapper instance.
  9732. * @example
  9733. *
  9734. * var object = { 'a': [{ 'b': { 'c': 3 } }, 4] };
  9735. *
  9736. * _(object).at(['a[0].b.c', 'a[1]']).value();
  9737. * // => [3, 4]
  9738. */
  9739. var wrapperAt = flatRest(function(paths) {
  9740. var length = paths.length,
  9741. start = length ? paths[0] : 0,
  9742. value = this.__wrapped__,
  9743. interceptor = function(object) { return baseAt(object, paths); };
  9744. if (length > 1 || this.__actions__.length ||
  9745. !(value instanceof LazyWrapper) || !isIndex(start)) {
  9746. return this.thru(interceptor);
  9747. }
  9748. value = value.slice(start, +start + (length ? 1 : 0));
  9749. value.__actions__.push({
  9750. 'func': thru,
  9751. 'args': [interceptor],
  9752. 'thisArg': undefined
  9753. });
  9754. return new LodashWrapper(value, this.__chain__).thru(function(array) {
  9755. if (length && !array.length) {
  9756. array.push(undefined);
  9757. }
  9758. return array;
  9759. });
  9760. });
  9761. /**
  9762. * Creates a `lodash` wrapper instance with explicit method chain sequences enabled.
  9763. *
  9764. * @name chain
  9765. * @memberOf _
  9766. * @since 0.1.0
  9767. * @category Seq
  9768. * @returns {Object} Returns the new `lodash` wrapper instance.
  9769. * @example
  9770. *
  9771. * var users = [
  9772. * { 'user': 'barney', 'age': 36 },
  9773. * { 'user': 'fred', 'age': 40 }
  9774. * ];
  9775. *
  9776. * // A sequence without explicit chaining.
  9777. * _(users).head();
  9778. * // => { 'user': 'barney', 'age': 36 }
  9779. *
  9780. * // A sequence with explicit chaining.
  9781. * _(users)
  9782. * .chain()
  9783. * .head()
  9784. * .pick('user')
  9785. * .value();
  9786. * // => { 'user': 'barney' }
  9787. */
  9788. function wrapperChain() {
  9789. return chain(this);
  9790. }
  9791. /**
  9792. * Executes the chain sequence and returns the wrapped result.
  9793. *
  9794. * @name commit
  9795. * @memberOf _
  9796. * @since 3.2.0
  9797. * @category Seq
  9798. * @returns {Object} Returns the new `lodash` wrapper instance.
  9799. * @example
  9800. *
  9801. * var array = [1, 2];
  9802. * var wrapped = _(array).push(3);
  9803. *
  9804. * console.log(array);
  9805. * // => [1, 2]
  9806. *
  9807. * wrapped = wrapped.commit();
  9808. * console.log(array);
  9809. * // => [1, 2, 3]
  9810. *
  9811. * wrapped.last();
  9812. * // => 3
  9813. *
  9814. * console.log(array);
  9815. * // => [1, 2, 3]
  9816. */
  9817. function wrapperCommit() {
  9818. return new LodashWrapper(this.value(), this.__chain__);
  9819. }
  9820. /**
  9821. * Gets the next value on a wrapped object following the
  9822. * [iterator protocol](https://mdn.io/iteration_protocols#iterator).
  9823. *
  9824. * @name next
  9825. * @memberOf _
  9826. * @since 4.0.0
  9827. * @category Seq
  9828. * @returns {Object} Returns the next iterator value.
  9829. * @example
  9830. *
  9831. * var wrapped = _([1, 2]);
  9832. *
  9833. * wrapped.next();
  9834. * // => { 'done': false, 'value': 1 }
  9835. *
  9836. * wrapped.next();
  9837. * // => { 'done': false, 'value': 2 }
  9838. *
  9839. * wrapped.next();
  9840. * // => { 'done': true, 'value': undefined }
  9841. */
  9842. function wrapperNext() {
  9843. if (this.__values__ === undefined) {
  9844. this.__values__ = toArray(this.value());
  9845. }
  9846. var done = this.__index__ >= this.__values__.length,
  9847. value = done ? undefined : this.__values__[this.__index__++];
  9848. return { 'done': done, 'value': value };
  9849. }
  9850. /**
  9851. * Enables the wrapper to be iterable.
  9852. *
  9853. * @name Symbol.iterator
  9854. * @memberOf _
  9855. * @since 4.0.0
  9856. * @category Seq
  9857. * @returns {Object} Returns the wrapper object.
  9858. * @example
  9859. *
  9860. * var wrapped = _([1, 2]);
  9861. *
  9862. * wrapped[Symbol.iterator]() === wrapped;
  9863. * // => true
  9864. *
  9865. * Array.from(wrapped);
  9866. * // => [1, 2]
  9867. */
  9868. function wrapperToIterator() {
  9869. return this;
  9870. }
  9871. /**
  9872. * Creates a clone of the chain sequence planting `value` as the wrapped value.
  9873. *
  9874. * @name plant
  9875. * @memberOf _
  9876. * @since 3.2.0
  9877. * @category Seq
  9878. * @param {*} value The value to plant.
  9879. * @returns {Object} Returns the new `lodash` wrapper instance.
  9880. * @example
  9881. *
  9882. * function square(n) {
  9883. * return n * n;
  9884. * }
  9885. *
  9886. * var wrapped = _([1, 2]).map(square);
  9887. * var other = wrapped.plant([3, 4]);
  9888. *
  9889. * other.value();
  9890. * // => [9, 16]
  9891. *
  9892. * wrapped.value();
  9893. * // => [1, 4]
  9894. */
  9895. function wrapperPlant(value) {
  9896. var result,
  9897. parent = this;
  9898. while (parent instanceof baseLodash) {
  9899. var clone = wrapperClone(parent);
  9900. clone.__index__ = 0;
  9901. clone.__values__ = undefined;
  9902. if (result) {
  9903. previous.__wrapped__ = clone;
  9904. } else {
  9905. result = clone;
  9906. }
  9907. var previous = clone;
  9908. parent = parent.__wrapped__;
  9909. }
  9910. previous.__wrapped__ = value;
  9911. return result;
  9912. }
  9913. /**
  9914. * This method is the wrapper version of `_.reverse`.
  9915. *
  9916. * **Note:** This method mutates the wrapped array.
  9917. *
  9918. * @name reverse
  9919. * @memberOf _
  9920. * @since 0.1.0
  9921. * @category Seq
  9922. * @returns {Object} Returns the new `lodash` wrapper instance.
  9923. * @example
  9924. *
  9925. * var array = [1, 2, 3];
  9926. *
  9927. * _(array).reverse().value()
  9928. * // => [3, 2, 1]
  9929. *
  9930. * console.log(array);
  9931. * // => [3, 2, 1]
  9932. */
  9933. function wrapperReverse() {
  9934. var value = this.__wrapped__;
  9935. if (value instanceof LazyWrapper) {
  9936. var wrapped = value;
  9937. if (this.__actions__.length) {
  9938. wrapped = new LazyWrapper(this);
  9939. }
  9940. wrapped = wrapped.reverse();
  9941. wrapped.__actions__.push({
  9942. 'func': thru,
  9943. 'args': [reverse],
  9944. 'thisArg': undefined
  9945. });
  9946. return new LodashWrapper(wrapped, this.__chain__);
  9947. }
  9948. return this.thru(reverse);
  9949. }
  9950. /**
  9951. * Executes the chain sequence to resolve the unwrapped value.
  9952. *
  9953. * @name value
  9954. * @memberOf _
  9955. * @since 0.1.0
  9956. * @alias toJSON, valueOf
  9957. * @category Seq
  9958. * @returns {*} Returns the resolved unwrapped value.
  9959. * @example
  9960. *
  9961. * _([1, 2, 3]).value();
  9962. * // => [1, 2, 3]
  9963. */
  9964. function wrapperValue() {
  9965. return baseWrapperValue(this.__wrapped__, this.__actions__);
  9966. }
  9967. /*------------------------------------------------------------------------*/
  9968. /**
  9969. * Creates an object composed of keys generated from the results of running
  9970. * each element of `collection` thru `iteratee`. The corresponding value of
  9971. * each key is the number of times the key was returned by `iteratee`. The
  9972. * iteratee is invoked with one argument: (value).
  9973. *
  9974. * @static
  9975. * @memberOf _
  9976. * @since 0.5.0
  9977. * @category Collection
  9978. * @param {Array|Object} collection The collection to iterate over.
  9979. * @param {Function} [iteratee=_.identity] The iteratee to transform keys.
  9980. * @returns {Object} Returns the composed aggregate object.
  9981. * @example
  9982. *
  9983. * _.countBy([6.1, 4.2, 6.3], Math.floor);
  9984. * // => { '4': 1, '6': 2 }
  9985. *
  9986. * // The `_.property` iteratee shorthand.
  9987. * _.countBy(['one', 'two', 'three'], 'length');
  9988. * // => { '3': 2, '5': 1 }
  9989. */
  9990. var countBy = createAggregator(function(result, value, key) {
  9991. if (hasOwnProperty.call(result, key)) {
  9992. ++result[key];
  9993. } else {
  9994. baseAssignValue(result, key, 1);
  9995. }
  9996. });
  9997. /**
  9998. * Checks if `predicate` returns truthy for **all** elements of `collection`.
  9999. * Iteration is stopped once `predicate` returns falsey. The predicate is
  10000. * invoked with three arguments: (value, index|key, collection).
  10001. *
  10002. * **Note:** This method returns `true` for
  10003. * [empty collections](https://en.wikipedia.org/wiki/Empty_set) because
  10004. * [everything is true](https://en.wikipedia.org/wiki/Vacuous_truth) of
  10005. * elements of empty collections.
  10006. *
  10007. * @static
  10008. * @memberOf _
  10009. * @since 0.1.0
  10010. * @category Collection
  10011. * @param {Array|Object} collection The collection to iterate over.
  10012. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  10013. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  10014. * @returns {boolean} Returns `true` if all elements pass the predicate check,
  10015. * else `false`.
  10016. * @example
  10017. *
  10018. * _.every([true, 1, null, 'yes'], Boolean);
  10019. * // => false
  10020. *
  10021. * var users = [
  10022. * { 'user': 'barney', 'age': 36, 'active': false },
  10023. * { 'user': 'fred', 'age': 40, 'active': false }
  10024. * ];
  10025. *
  10026. * // The `_.matches` iteratee shorthand.
  10027. * _.every(users, { 'user': 'barney', 'active': false });
  10028. * // => false
  10029. *
  10030. * // The `_.matchesProperty` iteratee shorthand.
  10031. * _.every(users, ['active', false]);
  10032. * // => true
  10033. *
  10034. * // The `_.property` iteratee shorthand.
  10035. * _.every(users, 'active');
  10036. * // => false
  10037. */
  10038. function every(collection, predicate, guard) {
  10039. var func = isArray(collection) ? arrayEvery : baseEvery;
  10040. if (guard && isIterateeCall(collection, predicate, guard)) {
  10041. predicate = undefined;
  10042. }
  10043. return func(collection, getIteratee(predicate, 3));
  10044. }
  10045. /**
  10046. * Iterates over elements of `collection`, returning an array of all elements
  10047. * `predicate` returns truthy for. The predicate is invoked with three
  10048. * arguments: (value, index|key, collection).
  10049. *
  10050. * **Note:** Unlike `_.remove`, this method returns a new array.
  10051. *
  10052. * @static
  10053. * @memberOf _
  10054. * @since 0.1.0
  10055. * @category Collection
  10056. * @param {Array|Object} collection The collection to iterate over.
  10057. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  10058. * @returns {Array} Returns the new filtered array.
  10059. * @see _.reject
  10060. * @example
  10061. *
  10062. * var users = [
  10063. * { 'user': 'barney', 'age': 36, 'active': true },
  10064. * { 'user': 'fred', 'age': 40, 'active': false }
  10065. * ];
  10066. *
  10067. * _.filter(users, function(o) { return !o.active; });
  10068. * // => objects for ['fred']
  10069. *
  10070. * // The `_.matches` iteratee shorthand.
  10071. * _.filter(users, { 'age': 36, 'active': true });
  10072. * // => objects for ['barney']
  10073. *
  10074. * // The `_.matchesProperty` iteratee shorthand.
  10075. * _.filter(users, ['active', false]);
  10076. * // => objects for ['fred']
  10077. *
  10078. * // The `_.property` iteratee shorthand.
  10079. * _.filter(users, 'active');
  10080. * // => objects for ['barney']
  10081. *
  10082. * // Combining several predicates using `_.overEvery` or `_.overSome`.
  10083. * _.filter(users, _.overSome([{ 'age': 36 }, ['age', 40]]));
  10084. * // => objects for ['fred', 'barney']
  10085. */
  10086. function filter(collection, predicate) {
  10087. var func = isArray(collection) ? arrayFilter : baseFilter;
  10088. return func(collection, getIteratee(predicate, 3));
  10089. }
  10090. /**
  10091. * Iterates over elements of `collection`, returning the first element
  10092. * `predicate` returns truthy for. The predicate is invoked with three
  10093. * arguments: (value, index|key, collection).
  10094. *
  10095. * @static
  10096. * @memberOf _
  10097. * @since 0.1.0
  10098. * @category Collection
  10099. * @param {Array|Object} collection The collection to inspect.
  10100. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  10101. * @param {number} [fromIndex=0] The index to search from.
  10102. * @returns {*} Returns the matched element, else `undefined`.
  10103. * @example
  10104. *
  10105. * var users = [
  10106. * { 'user': 'barney', 'age': 36, 'active': true },
  10107. * { 'user': 'fred', 'age': 40, 'active': false },
  10108. * { 'user': 'pebbles', 'age': 1, 'active': true }
  10109. * ];
  10110. *
  10111. * _.find(users, function(o) { return o.age < 40; });
  10112. * // => object for 'barney'
  10113. *
  10114. * // The `_.matches` iteratee shorthand.
  10115. * _.find(users, { 'age': 1, 'active': true });
  10116. * // => object for 'pebbles'
  10117. *
  10118. * // The `_.matchesProperty` iteratee shorthand.
  10119. * _.find(users, ['active', false]);
  10120. * // => object for 'fred'
  10121. *
  10122. * // The `_.property` iteratee shorthand.
  10123. * _.find(users, 'active');
  10124. * // => object for 'barney'
  10125. */
  10126. var find = createFind(findIndex);
  10127. /**
  10128. * This method is like `_.find` except that it iterates over elements of
  10129. * `collection` from right to left.
  10130. *
  10131. * @static
  10132. * @memberOf _
  10133. * @since 2.0.0
  10134. * @category Collection
  10135. * @param {Array|Object} collection The collection to inspect.
  10136. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  10137. * @param {number} [fromIndex=collection.length-1] The index to search from.
  10138. * @returns {*} Returns the matched element, else `undefined`.
  10139. * @example
  10140. *
  10141. * _.findLast([1, 2, 3, 4], function(n) {
  10142. * return n % 2 == 1;
  10143. * });
  10144. * // => 3
  10145. */
  10146. var findLast = createFind(findLastIndex);
  10147. /**
  10148. * Creates a flattened array of values by running each element in `collection`
  10149. * thru `iteratee` and flattening the mapped results. The iteratee is invoked
  10150. * with three arguments: (value, index|key, collection).
  10151. *
  10152. * @static
  10153. * @memberOf _
  10154. * @since 4.0.0
  10155. * @category Collection
  10156. * @param {Array|Object} collection The collection to iterate over.
  10157. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  10158. * @returns {Array} Returns the new flattened array.
  10159. * @example
  10160. *
  10161. * function duplicate(n) {
  10162. * return [n, n];
  10163. * }
  10164. *
  10165. * _.flatMap([1, 2], duplicate);
  10166. * // => [1, 1, 2, 2]
  10167. */
  10168. function flatMap(collection, iteratee) {
  10169. return baseFlatten(map(collection, iteratee), 1);
  10170. }
  10171. /**
  10172. * This method is like `_.flatMap` except that it recursively flattens the
  10173. * mapped results.
  10174. *
  10175. * @static
  10176. * @memberOf _
  10177. * @since 4.7.0
  10178. * @category Collection
  10179. * @param {Array|Object} collection The collection to iterate over.
  10180. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  10181. * @returns {Array} Returns the new flattened array.
  10182. * @example
  10183. *
  10184. * function duplicate(n) {
  10185. * return [[[n, n]]];
  10186. * }
  10187. *
  10188. * _.flatMapDeep([1, 2], duplicate);
  10189. * // => [1, 1, 2, 2]
  10190. */
  10191. function flatMapDeep(collection, iteratee) {
  10192. return baseFlatten(map(collection, iteratee), INFINITY);
  10193. }
  10194. /**
  10195. * This method is like `_.flatMap` except that it recursively flattens the
  10196. * mapped results up to `depth` times.
  10197. *
  10198. * @static
  10199. * @memberOf _
  10200. * @since 4.7.0
  10201. * @category Collection
  10202. * @param {Array|Object} collection The collection to iterate over.
  10203. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  10204. * @param {number} [depth=1] The maximum recursion depth.
  10205. * @returns {Array} Returns the new flattened array.
  10206. * @example
  10207. *
  10208. * function duplicate(n) {
  10209. * return [[[n, n]]];
  10210. * }
  10211. *
  10212. * _.flatMapDepth([1, 2], duplicate, 2);
  10213. * // => [[1, 1], [2, 2]]
  10214. */
  10215. function flatMapDepth(collection, iteratee, depth) {
  10216. depth = depth === undefined ? 1 : toInteger(depth);
  10217. return baseFlatten(map(collection, iteratee), depth);
  10218. }
  10219. /**
  10220. * Iterates over elements of `collection` and invokes `iteratee` for each element.
  10221. * The iteratee is invoked with three arguments: (value, index|key, collection).
  10222. * Iteratee functions may exit iteration early by explicitly returning `false`.
  10223. *
  10224. * **Note:** As with other "Collections" methods, objects with a "length"
  10225. * property are iterated like arrays. To avoid this behavior use `_.forIn`
  10226. * or `_.forOwn` for object iteration.
  10227. *
  10228. * @static
  10229. * @memberOf _
  10230. * @since 0.1.0
  10231. * @alias each
  10232. * @category Collection
  10233. * @param {Array|Object} collection The collection to iterate over.
  10234. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  10235. * @returns {Array|Object} Returns `collection`.
  10236. * @see _.forEachRight
  10237. * @example
  10238. *
  10239. * _.forEach([1, 2], function(value) {
  10240. * console.log(value);
  10241. * });
  10242. * // => Logs `1` then `2`.
  10243. *
  10244. * _.forEach({ 'a': 1, 'b': 2 }, function(value, key) {
  10245. * console.log(key);
  10246. * });
  10247. * // => Logs 'a' then 'b' (iteration order is not guaranteed).
  10248. */
  10249. function forEach(collection, iteratee) {
  10250. var func = isArray(collection) ? arrayEach : baseEach;
  10251. return func(collection, getIteratee(iteratee, 3));
  10252. }
  10253. /**
  10254. * This method is like `_.forEach` except that it iterates over elements of
  10255. * `collection` from right to left.
  10256. *
  10257. * @static
  10258. * @memberOf _
  10259. * @since 2.0.0
  10260. * @alias eachRight
  10261. * @category Collection
  10262. * @param {Array|Object} collection The collection to iterate over.
  10263. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  10264. * @returns {Array|Object} Returns `collection`.
  10265. * @see _.forEach
  10266. * @example
  10267. *
  10268. * _.forEachRight([1, 2], function(value) {
  10269. * console.log(value);
  10270. * });
  10271. * // => Logs `2` then `1`.
  10272. */
  10273. function forEachRight(collection, iteratee) {
  10274. var func = isArray(collection) ? arrayEachRight : baseEachRight;
  10275. return func(collection, getIteratee(iteratee, 3));
  10276. }
  10277. /**
  10278. * Creates an object composed of keys generated from the results of running
  10279. * each element of `collection` thru `iteratee`. The order of grouped values
  10280. * is determined by the order they occur in `collection`. The corresponding
  10281. * value of each key is an array of elements responsible for generating the
  10282. * key. The iteratee is invoked with one argument: (value).
  10283. *
  10284. * @static
  10285. * @memberOf _
  10286. * @since 0.1.0
  10287. * @category Collection
  10288. * @param {Array|Object} collection The collection to iterate over.
  10289. * @param {Function} [iteratee=_.identity] The iteratee to transform keys.
  10290. * @returns {Object} Returns the composed aggregate object.
  10291. * @example
  10292. *
  10293. * _.groupBy([6.1, 4.2, 6.3], Math.floor);
  10294. * // => { '4': [4.2], '6': [6.1, 6.3] }
  10295. *
  10296. * // The `_.property` iteratee shorthand.
  10297. * _.groupBy(['one', 'two', 'three'], 'length');
  10298. * // => { '3': ['one', 'two'], '5': ['three'] }
  10299. */
  10300. var groupBy = createAggregator(function(result, value, key) {
  10301. if (hasOwnProperty.call(result, key)) {
  10302. result[key].push(value);
  10303. } else {
  10304. baseAssignValue(result, key, [value]);
  10305. }
  10306. });
  10307. /**
  10308. * Checks if `value` is in `collection`. If `collection` is a string, it's
  10309. * checked for a substring of `value`, otherwise
  10310. * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
  10311. * is used for equality comparisons. If `fromIndex` is negative, it's used as
  10312. * the offset from the end of `collection`.
  10313. *
  10314. * @static
  10315. * @memberOf _
  10316. * @since 0.1.0
  10317. * @category Collection
  10318. * @param {Array|Object|string} collection The collection to inspect.
  10319. * @param {*} value The value to search for.
  10320. * @param {number} [fromIndex=0] The index to search from.
  10321. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.reduce`.
  10322. * @returns {boolean} Returns `true` if `value` is found, else `false`.
  10323. * @example
  10324. *
  10325. * _.includes([1, 2, 3], 1);
  10326. * // => true
  10327. *
  10328. * _.includes([1, 2, 3], 1, 2);
  10329. * // => false
  10330. *
  10331. * _.includes({ 'a': 1, 'b': 2 }, 1);
  10332. * // => true
  10333. *
  10334. * _.includes('abcd', 'bc');
  10335. * // => true
  10336. */
  10337. function includes(collection, value, fromIndex, guard) {
  10338. collection = isArrayLike(collection) ? collection : values(collection);
  10339. fromIndex = (fromIndex && !guard) ? toInteger(fromIndex) : 0;
  10340. var length = collection.length;
  10341. if (fromIndex < 0) {
  10342. fromIndex = nativeMax(length + fromIndex, 0);
  10343. }
  10344. return isString(collection)
  10345. ? (fromIndex <= length && collection.indexOf(value, fromIndex) > -1)
  10346. : (!!length && baseIndexOf(collection, value, fromIndex) > -1);
  10347. }
  10348. /**
  10349. * Invokes the method at `path` of each element in `collection`, returning
  10350. * an array of the results of each invoked method. Any additional arguments
  10351. * are provided to each invoked method. If `path` is a function, it's invoked
  10352. * for, and `this` bound to, each element in `collection`.
  10353. *
  10354. * @static
  10355. * @memberOf _
  10356. * @since 4.0.0
  10357. * @category Collection
  10358. * @param {Array|Object} collection The collection to iterate over.
  10359. * @param {Array|Function|string} path The path of the method to invoke or
  10360. * the function invoked per iteration.
  10361. * @param {...*} [args] The arguments to invoke each method with.
  10362. * @returns {Array} Returns the array of results.
  10363. * @example
  10364. *
  10365. * _.invokeMap([[5, 1, 7], [3, 2, 1]], 'sort');
  10366. * // => [[1, 5, 7], [1, 2, 3]]
  10367. *
  10368. * _.invokeMap([123, 456], String.prototype.split, '');
  10369. * // => [['1', '2', '3'], ['4', '5', '6']]
  10370. */
  10371. var invokeMap = baseRest(function(collection, path, args) {
  10372. var index = -1,
  10373. isFunc = typeof path == 'function',
  10374. result = isArrayLike(collection) ? Array(collection.length) : [];
  10375. baseEach(collection, function(value) {
  10376. result[++index] = isFunc ? apply(path, value, args) : baseInvoke(value, path, args);
  10377. });
  10378. return result;
  10379. });
  10380. /**
  10381. * Creates an object composed of keys generated from the results of running
  10382. * each element of `collection` thru `iteratee`. The corresponding value of
  10383. * each key is the last element responsible for generating the key. The
  10384. * iteratee is invoked with one argument: (value).
  10385. *
  10386. * @static
  10387. * @memberOf _
  10388. * @since 4.0.0
  10389. * @category Collection
  10390. * @param {Array|Object} collection The collection to iterate over.
  10391. * @param {Function} [iteratee=_.identity] The iteratee to transform keys.
  10392. * @returns {Object} Returns the composed aggregate object.
  10393. * @example
  10394. *
  10395. * var array = [
  10396. * { 'dir': 'left', 'code': 97 },
  10397. * { 'dir': 'right', 'code': 100 }
  10398. * ];
  10399. *
  10400. * _.keyBy(array, function(o) {
  10401. * return String.fromCharCode(o.code);
  10402. * });
  10403. * // => { 'a': { 'dir': 'left', 'code': 97 }, 'd': { 'dir': 'right', 'code': 100 } }
  10404. *
  10405. * _.keyBy(array, 'dir');
  10406. * // => { 'left': { 'dir': 'left', 'code': 97 }, 'right': { 'dir': 'right', 'code': 100 } }
  10407. */
  10408. var keyBy = createAggregator(function(result, value, key) {
  10409. baseAssignValue(result, key, value);
  10410. });
  10411. /**
  10412. * Creates an array of values by running each element in `collection` thru
  10413. * `iteratee`. The iteratee is invoked with three arguments:
  10414. * (value, index|key, collection).
  10415. *
  10416. * Many lodash methods are guarded to work as iteratees for methods like
  10417. * `_.every`, `_.filter`, `_.map`, `_.mapValues`, `_.reject`, and `_.some`.
  10418. *
  10419. * The guarded methods are:
  10420. * `ary`, `chunk`, `curry`, `curryRight`, `drop`, `dropRight`, `every`,
  10421. * `fill`, `invert`, `parseInt`, `random`, `range`, `rangeRight`, `repeat`,
  10422. * `sampleSize`, `slice`, `some`, `sortBy`, `split`, `take`, `takeRight`,
  10423. * `template`, `trim`, `trimEnd`, `trimStart`, and `words`
  10424. *
  10425. * @static
  10426. * @memberOf _
  10427. * @since 0.1.0
  10428. * @category Collection
  10429. * @param {Array|Object} collection The collection to iterate over.
  10430. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  10431. * @returns {Array} Returns the new mapped array.
  10432. * @example
  10433. *
  10434. * function square(n) {
  10435. * return n * n;
  10436. * }
  10437. *
  10438. * _.map([4, 8], square);
  10439. * // => [16, 64]
  10440. *
  10441. * _.map({ 'a': 4, 'b': 8 }, square);
  10442. * // => [16, 64] (iteration order is not guaranteed)
  10443. *
  10444. * var users = [
  10445. * { 'user': 'barney' },
  10446. * { 'user': 'fred' }
  10447. * ];
  10448. *
  10449. * // The `_.property` iteratee shorthand.
  10450. * _.map(users, 'user');
  10451. * // => ['barney', 'fred']
  10452. */
  10453. function map(collection, iteratee) {
  10454. var func = isArray(collection) ? arrayMap : baseMap;
  10455. return func(collection, getIteratee(iteratee, 3));
  10456. }
  10457. /**
  10458. * This method is like `_.sortBy` except that it allows specifying the sort
  10459. * orders of the iteratees to sort by. If `orders` is unspecified, all values
  10460. * are sorted in ascending order. Otherwise, specify an order of "desc" for
  10461. * descending or "asc" for ascending sort order of corresponding values.
  10462. *
  10463. * @static
  10464. * @memberOf _
  10465. * @since 4.0.0
  10466. * @category Collection
  10467. * @param {Array|Object} collection The collection to iterate over.
  10468. * @param {Array[]|Function[]|Object[]|string[]} [iteratees=[_.identity]]
  10469. * The iteratees to sort by.
  10470. * @param {string[]} [orders] The sort orders of `iteratees`.
  10471. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.reduce`.
  10472. * @returns {Array} Returns the new sorted array.
  10473. * @example
  10474. *
  10475. * var users = [
  10476. * { 'user': 'fred', 'age': 48 },
  10477. * { 'user': 'barney', 'age': 34 },
  10478. * { 'user': 'fred', 'age': 40 },
  10479. * { 'user': 'barney', 'age': 36 }
  10480. * ];
  10481. *
  10482. * // Sort by `user` in ascending order and by `age` in descending order.
  10483. * _.orderBy(users, ['user', 'age'], ['asc', 'desc']);
  10484. * // => objects for [['barney', 36], ['barney', 34], ['fred', 48], ['fred', 40]]
  10485. */
  10486. function orderBy(collection, iteratees, orders, guard) {
  10487. if (collection == null) {
  10488. return [];
  10489. }
  10490. if (!isArray(iteratees)) {
  10491. iteratees = iteratees == null ? [] : [iteratees];
  10492. }
  10493. orders = guard ? undefined : orders;
  10494. if (!isArray(orders)) {
  10495. orders = orders == null ? [] : [orders];
  10496. }
  10497. return baseOrderBy(collection, iteratees, orders);
  10498. }
  10499. /**
  10500. * Creates an array of elements split into two groups, the first of which
  10501. * contains elements `predicate` returns truthy for, the second of which
  10502. * contains elements `predicate` returns falsey for. The predicate is
  10503. * invoked with one argument: (value).
  10504. *
  10505. * @static
  10506. * @memberOf _
  10507. * @since 3.0.0
  10508. * @category Collection
  10509. * @param {Array|Object} collection The collection to iterate over.
  10510. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  10511. * @returns {Array} Returns the array of grouped elements.
  10512. * @example
  10513. *
  10514. * var users = [
  10515. * { 'user': 'barney', 'age': 36, 'active': false },
  10516. * { 'user': 'fred', 'age': 40, 'active': true },
  10517. * { 'user': 'pebbles', 'age': 1, 'active': false }
  10518. * ];
  10519. *
  10520. * _.partition(users, function(o) { return o.active; });
  10521. * // => objects for [['fred'], ['barney', 'pebbles']]
  10522. *
  10523. * // The `_.matches` iteratee shorthand.
  10524. * _.partition(users, { 'age': 1, 'active': false });
  10525. * // => objects for [['pebbles'], ['barney', 'fred']]
  10526. *
  10527. * // The `_.matchesProperty` iteratee shorthand.
  10528. * _.partition(users, ['active', false]);
  10529. * // => objects for [['barney', 'pebbles'], ['fred']]
  10530. *
  10531. * // The `_.property` iteratee shorthand.
  10532. * _.partition(users, 'active');
  10533. * // => objects for [['fred'], ['barney', 'pebbles']]
  10534. */
  10535. var partition = createAggregator(function(result, value, key) {
  10536. result[key ? 0 : 1].push(value);
  10537. }, function() { return [[], []]; });
  10538. /**
  10539. * Reduces `collection` to a value which is the accumulated result of running
  10540. * each element in `collection` thru `iteratee`, where each successive
  10541. * invocation is supplied the return value of the previous. If `accumulator`
  10542. * is not given, the first element of `collection` is used as the initial
  10543. * value. The iteratee is invoked with four arguments:
  10544. * (accumulator, value, index|key, collection).
  10545. *
  10546. * Many lodash methods are guarded to work as iteratees for methods like
  10547. * `_.reduce`, `_.reduceRight`, and `_.transform`.
  10548. *
  10549. * The guarded methods are:
  10550. * `assign`, `defaults`, `defaultsDeep`, `includes`, `merge`, `orderBy`,
  10551. * and `sortBy`
  10552. *
  10553. * @static
  10554. * @memberOf _
  10555. * @since 0.1.0
  10556. * @category Collection
  10557. * @param {Array|Object} collection The collection to iterate over.
  10558. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  10559. * @param {*} [accumulator] The initial value.
  10560. * @returns {*} Returns the accumulated value.
  10561. * @see _.reduceRight
  10562. * @example
  10563. *
  10564. * _.reduce([1, 2], function(sum, n) {
  10565. * return sum + n;
  10566. * }, 0);
  10567. * // => 3
  10568. *
  10569. * _.reduce({ 'a': 1, 'b': 2, 'c': 1 }, function(result, value, key) {
  10570. * (result[value] || (result[value] = [])).push(key);
  10571. * return result;
  10572. * }, {});
  10573. * // => { '1': ['a', 'c'], '2': ['b'] } (iteration order is not guaranteed)
  10574. */
  10575. function reduce(collection, iteratee, accumulator) {
  10576. var func = isArray(collection) ? arrayReduce : baseReduce,
  10577. initAccum = arguments.length < 3;
  10578. return func(collection, getIteratee(iteratee, 4), accumulator, initAccum, baseEach);
  10579. }
  10580. /**
  10581. * This method is like `_.reduce` except that it iterates over elements of
  10582. * `collection` from right to left.
  10583. *
  10584. * @static
  10585. * @memberOf _
  10586. * @since 0.1.0
  10587. * @category Collection
  10588. * @param {Array|Object} collection The collection to iterate over.
  10589. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  10590. * @param {*} [accumulator] The initial value.
  10591. * @returns {*} Returns the accumulated value.
  10592. * @see _.reduce
  10593. * @example
  10594. *
  10595. * var array = [[0, 1], [2, 3], [4, 5]];
  10596. *
  10597. * _.reduceRight(array, function(flattened, other) {
  10598. * return flattened.concat(other);
  10599. * }, []);
  10600. * // => [4, 5, 2, 3, 0, 1]
  10601. */
  10602. function reduceRight(collection, iteratee, accumulator) {
  10603. var func = isArray(collection) ? arrayReduceRight : baseReduce,
  10604. initAccum = arguments.length < 3;
  10605. return func(collection, getIteratee(iteratee, 4), accumulator, initAccum, baseEachRight);
  10606. }
  10607. /**
  10608. * The opposite of `_.filter`; this method returns the elements of `collection`
  10609. * that `predicate` does **not** return truthy for.
  10610. *
  10611. * @static
  10612. * @memberOf _
  10613. * @since 0.1.0
  10614. * @category Collection
  10615. * @param {Array|Object} collection The collection to iterate over.
  10616. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  10617. * @returns {Array} Returns the new filtered array.
  10618. * @see _.filter
  10619. * @example
  10620. *
  10621. * var users = [
  10622. * { 'user': 'barney', 'age': 36, 'active': false },
  10623. * { 'user': 'fred', 'age': 40, 'active': true }
  10624. * ];
  10625. *
  10626. * _.reject(users, function(o) { return !o.active; });
  10627. * // => objects for ['fred']
  10628. *
  10629. * // The `_.matches` iteratee shorthand.
  10630. * _.reject(users, { 'age': 40, 'active': true });
  10631. * // => objects for ['barney']
  10632. *
  10633. * // The `_.matchesProperty` iteratee shorthand.
  10634. * _.reject(users, ['active', false]);
  10635. * // => objects for ['fred']
  10636. *
  10637. * // The `_.property` iteratee shorthand.
  10638. * _.reject(users, 'active');
  10639. * // => objects for ['barney']
  10640. */
  10641. function reject(collection, predicate) {
  10642. var func = isArray(collection) ? arrayFilter : baseFilter;
  10643. return func(collection, negate(getIteratee(predicate, 3)));
  10644. }
  10645. /**
  10646. * Gets a random element from `collection`.
  10647. *
  10648. * @static
  10649. * @memberOf _
  10650. * @since 2.0.0
  10651. * @category Collection
  10652. * @param {Array|Object} collection The collection to sample.
  10653. * @returns {*} Returns the random element.
  10654. * @example
  10655. *
  10656. * _.sample([1, 2, 3, 4]);
  10657. * // => 2
  10658. */
  10659. function sample(collection) {
  10660. var func = isArray(collection) ? arraySample : baseSample;
  10661. return func(collection);
  10662. }
  10663. /**
  10664. * Gets `n` random elements at unique keys from `collection` up to the
  10665. * size of `collection`.
  10666. *
  10667. * @static
  10668. * @memberOf _
  10669. * @since 4.0.0
  10670. * @category Collection
  10671. * @param {Array|Object} collection The collection to sample.
  10672. * @param {number} [n=1] The number of elements to sample.
  10673. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  10674. * @returns {Array} Returns the random elements.
  10675. * @example
  10676. *
  10677. * _.sampleSize([1, 2, 3], 2);
  10678. * // => [3, 1]
  10679. *
  10680. * _.sampleSize([1, 2, 3], 4);
  10681. * // => [2, 3, 1]
  10682. */
  10683. function sampleSize(collection, n, guard) {
  10684. if ((guard ? isIterateeCall(collection, n, guard) : n === undefined)) {
  10685. n = 1;
  10686. } else {
  10687. n = toInteger(n);
  10688. }
  10689. var func = isArray(collection) ? arraySampleSize : baseSampleSize;
  10690. return func(collection, n);
  10691. }
  10692. /**
  10693. * Creates an array of shuffled values, using a version of the
  10694. * [Fisher-Yates shuffle](https://en.wikipedia.org/wiki/Fisher-Yates_shuffle).
  10695. *
  10696. * @static
  10697. * @memberOf _
  10698. * @since 0.1.0
  10699. * @category Collection
  10700. * @param {Array|Object} collection The collection to shuffle.
  10701. * @returns {Array} Returns the new shuffled array.
  10702. * @example
  10703. *
  10704. * _.shuffle([1, 2, 3, 4]);
  10705. * // => [4, 1, 3, 2]
  10706. */
  10707. function shuffle(collection) {
  10708. var func = isArray(collection) ? arrayShuffle : baseShuffle;
  10709. return func(collection);
  10710. }
  10711. /**
  10712. * Gets the size of `collection` by returning its length for array-like
  10713. * values or the number of own enumerable string keyed properties for objects.
  10714. *
  10715. * @static
  10716. * @memberOf _
  10717. * @since 0.1.0
  10718. * @category Collection
  10719. * @param {Array|Object|string} collection The collection to inspect.
  10720. * @returns {number} Returns the collection size.
  10721. * @example
  10722. *
  10723. * _.size([1, 2, 3]);
  10724. * // => 3
  10725. *
  10726. * _.size({ 'a': 1, 'b': 2 });
  10727. * // => 2
  10728. *
  10729. * _.size('pebbles');
  10730. * // => 7
  10731. */
  10732. function size(collection) {
  10733. if (collection == null) {
  10734. return 0;
  10735. }
  10736. if (isArrayLike(collection)) {
  10737. return isString(collection) ? stringSize(collection) : collection.length;
  10738. }
  10739. var tag = getTag(collection);
  10740. if (tag == mapTag || tag == setTag) {
  10741. return collection.size;
  10742. }
  10743. return baseKeys(collection).length;
  10744. }
  10745. /**
  10746. * Checks if `predicate` returns truthy for **any** element of `collection`.
  10747. * Iteration is stopped once `predicate` returns truthy. The predicate is
  10748. * invoked with three arguments: (value, index|key, collection).
  10749. *
  10750. * @static
  10751. * @memberOf _
  10752. * @since 0.1.0
  10753. * @category Collection
  10754. * @param {Array|Object} collection The collection to iterate over.
  10755. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  10756. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  10757. * @returns {boolean} Returns `true` if any element passes the predicate check,
  10758. * else `false`.
  10759. * @example
  10760. *
  10761. * _.some([null, 0, 'yes', false], Boolean);
  10762. * // => true
  10763. *
  10764. * var users = [
  10765. * { 'user': 'barney', 'active': true },
  10766. * { 'user': 'fred', 'active': false }
  10767. * ];
  10768. *
  10769. * // The `_.matches` iteratee shorthand.
  10770. * _.some(users, { 'user': 'barney', 'active': false });
  10771. * // => false
  10772. *
  10773. * // The `_.matchesProperty` iteratee shorthand.
  10774. * _.some(users, ['active', false]);
  10775. * // => true
  10776. *
  10777. * // The `_.property` iteratee shorthand.
  10778. * _.some(users, 'active');
  10779. * // => true
  10780. */
  10781. function some(collection, predicate, guard) {
  10782. var func = isArray(collection) ? arraySome : baseSome;
  10783. if (guard && isIterateeCall(collection, predicate, guard)) {
  10784. predicate = undefined;
  10785. }
  10786. return func(collection, getIteratee(predicate, 3));
  10787. }
  10788. /**
  10789. * Creates an array of elements, sorted in ascending order by the results of
  10790. * running each element in a collection thru each iteratee. This method
  10791. * performs a stable sort, that is, it preserves the original sort order of
  10792. * equal elements. The iteratees are invoked with one argument: (value).
  10793. *
  10794. * @static
  10795. * @memberOf _
  10796. * @since 0.1.0
  10797. * @category Collection
  10798. * @param {Array|Object} collection The collection to iterate over.
  10799. * @param {...(Function|Function[])} [iteratees=[_.identity]]
  10800. * The iteratees to sort by.
  10801. * @returns {Array} Returns the new sorted array.
  10802. * @example
  10803. *
  10804. * var users = [
  10805. * { 'user': 'fred', 'age': 48 },
  10806. * { 'user': 'barney', 'age': 36 },
  10807. * { 'user': 'fred', 'age': 30 },
  10808. * { 'user': 'barney', 'age': 34 }
  10809. * ];
  10810. *
  10811. * _.sortBy(users, [function(o) { return o.user; }]);
  10812. * // => objects for [['barney', 36], ['barney', 34], ['fred', 48], ['fred', 30]]
  10813. *
  10814. * _.sortBy(users, ['user', 'age']);
  10815. * // => objects for [['barney', 34], ['barney', 36], ['fred', 30], ['fred', 48]]
  10816. */
  10817. var sortBy = baseRest(function(collection, iteratees) {
  10818. if (collection == null) {
  10819. return [];
  10820. }
  10821. var length = iteratees.length;
  10822. if (length > 1 && isIterateeCall(collection, iteratees[0], iteratees[1])) {
  10823. iteratees = [];
  10824. } else if (length > 2 && isIterateeCall(iteratees[0], iteratees[1], iteratees[2])) {
  10825. iteratees = [iteratees[0]];
  10826. }
  10827. return baseOrderBy(collection, baseFlatten(iteratees, 1), []);
  10828. });
  10829. /*------------------------------------------------------------------------*/
  10830. /**
  10831. * Gets the timestamp of the number of milliseconds that have elapsed since
  10832. * the Unix epoch (1 January 1970 00:00:00 UTC).
  10833. *
  10834. * @static
  10835. * @memberOf _
  10836. * @since 2.4.0
  10837. * @category Date
  10838. * @returns {number} Returns the timestamp.
  10839. * @example
  10840. *
  10841. * _.defer(function(stamp) {
  10842. * console.log(_.now() - stamp);
  10843. * }, _.now());
  10844. * // => Logs the number of milliseconds it took for the deferred invocation.
  10845. */
  10846. var now = ctxNow || function() {
  10847. return root.Date.now();
  10848. };
  10849. /*------------------------------------------------------------------------*/
  10850. /**
  10851. * The opposite of `_.before`; this method creates a function that invokes
  10852. * `func` once it's called `n` or more times.
  10853. *
  10854. * @static
  10855. * @memberOf _
  10856. * @since 0.1.0
  10857. * @category Function
  10858. * @param {number} n The number of calls before `func` is invoked.
  10859. * @param {Function} func The function to restrict.
  10860. * @returns {Function} Returns the new restricted function.
  10861. * @example
  10862. *
  10863. * var saves = ['profile', 'settings'];
  10864. *
  10865. * var done = _.after(saves.length, function() {
  10866. * console.log('done saving!');
  10867. * });
  10868. *
  10869. * _.forEach(saves, function(type) {
  10870. * asyncSave({ 'type': type, 'complete': done });
  10871. * });
  10872. * // => Logs 'done saving!' after the two async saves have completed.
  10873. */
  10874. function after(n, func) {
  10875. if (typeof func != 'function') {
  10876. throw new TypeError(FUNC_ERROR_TEXT);
  10877. }
  10878. n = toInteger(n);
  10879. return function() {
  10880. if (--n < 1) {
  10881. return func.apply(this, arguments);
  10882. }
  10883. };
  10884. }
  10885. /**
  10886. * Creates a function that invokes `func`, with up to `n` arguments,
  10887. * ignoring any additional arguments.
  10888. *
  10889. * @static
  10890. * @memberOf _
  10891. * @since 3.0.0
  10892. * @category Function
  10893. * @param {Function} func The function to cap arguments for.
  10894. * @param {number} [n=func.length] The arity cap.
  10895. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  10896. * @returns {Function} Returns the new capped function.
  10897. * @example
  10898. *
  10899. * _.map(['6', '8', '10'], _.ary(parseInt, 1));
  10900. * // => [6, 8, 10]
  10901. */
  10902. function ary(func, n, guard) {
  10903. n = guard ? undefined : n;
  10904. n = (func && n == null) ? func.length : n;
  10905. return createWrap(func, WRAP_ARY_FLAG, undefined, undefined, undefined, undefined, n);
  10906. }
  10907. /**
  10908. * Creates a function that invokes `func`, with the `this` binding and arguments
  10909. * of the created function, while it's called less than `n` times. Subsequent
  10910. * calls to the created function return the result of the last `func` invocation.
  10911. *
  10912. * @static
  10913. * @memberOf _
  10914. * @since 3.0.0
  10915. * @category Function
  10916. * @param {number} n The number of calls at which `func` is no longer invoked.
  10917. * @param {Function} func The function to restrict.
  10918. * @returns {Function} Returns the new restricted function.
  10919. * @example
  10920. *
  10921. * jQuery(element).on('click', _.before(5, addContactToList));
  10922. * // => Allows adding up to 4 contacts to the list.
  10923. */
  10924. function before(n, func) {
  10925. var result;
  10926. if (typeof func != 'function') {
  10927. throw new TypeError(FUNC_ERROR_TEXT);
  10928. }
  10929. n = toInteger(n);
  10930. return function() {
  10931. if (--n > 0) {
  10932. result = func.apply(this, arguments);
  10933. }
  10934. if (n <= 1) {
  10935. func = undefined;
  10936. }
  10937. return result;
  10938. };
  10939. }
  10940. /**
  10941. * Creates a function that invokes `func` with the `this` binding of `thisArg`
  10942. * and `partials` prepended to the arguments it receives.
  10943. *
  10944. * The `_.bind.placeholder` value, which defaults to `_` in monolithic builds,
  10945. * may be used as a placeholder for partially applied arguments.
  10946. *
  10947. * **Note:** Unlike native `Function#bind`, this method doesn't set the "length"
  10948. * property of bound functions.
  10949. *
  10950. * @static
  10951. * @memberOf _
  10952. * @since 0.1.0
  10953. * @category Function
  10954. * @param {Function} func The function to bind.
  10955. * @param {*} thisArg The `this` binding of `func`.
  10956. * @param {...*} [partials] The arguments to be partially applied.
  10957. * @returns {Function} Returns the new bound function.
  10958. * @example
  10959. *
  10960. * function greet(greeting, punctuation) {
  10961. * return greeting + ' ' + this.user + punctuation;
  10962. * }
  10963. *
  10964. * var object = { 'user': 'fred' };
  10965. *
  10966. * var bound = _.bind(greet, object, 'hi');
  10967. * bound('!');
  10968. * // => 'hi fred!'
  10969. *
  10970. * // Bound with placeholders.
  10971. * var bound = _.bind(greet, object, _, '!');
  10972. * bound('hi');
  10973. * // => 'hi fred!'
  10974. */
  10975. var bind = baseRest(function(func, thisArg, partials) {
  10976. var bitmask = WRAP_BIND_FLAG;
  10977. if (partials.length) {
  10978. var holders = replaceHolders(partials, getHolder(bind));
  10979. bitmask |= WRAP_PARTIAL_FLAG;
  10980. }
  10981. return createWrap(func, bitmask, thisArg, partials, holders);
  10982. });
  10983. /**
  10984. * Creates a function that invokes the method at `object[key]` with `partials`
  10985. * prepended to the arguments it receives.
  10986. *
  10987. * This method differs from `_.bind` by allowing bound functions to reference
  10988. * methods that may be redefined or don't yet exist. See
  10989. * [Peter Michaux's article](http://peter.michaux.ca/articles/lazy-function-definition-pattern)
  10990. * for more details.
  10991. *
  10992. * The `_.bindKey.placeholder` value, which defaults to `_` in monolithic
  10993. * builds, may be used as a placeholder for partially applied arguments.
  10994. *
  10995. * @static
  10996. * @memberOf _
  10997. * @since 0.10.0
  10998. * @category Function
  10999. * @param {Object} object The object to invoke the method on.
  11000. * @param {string} key The key of the method.
  11001. * @param {...*} [partials] The arguments to be partially applied.
  11002. * @returns {Function} Returns the new bound function.
  11003. * @example
  11004. *
  11005. * var object = {
  11006. * 'user': 'fred',
  11007. * 'greet': function(greeting, punctuation) {
  11008. * return greeting + ' ' + this.user + punctuation;
  11009. * }
  11010. * };
  11011. *
  11012. * var bound = _.bindKey(object, 'greet', 'hi');
  11013. * bound('!');
  11014. * // => 'hi fred!'
  11015. *
  11016. * object.greet = function(greeting, punctuation) {
  11017. * return greeting + 'ya ' + this.user + punctuation;
  11018. * };
  11019. *
  11020. * bound('!');
  11021. * // => 'hiya fred!'
  11022. *
  11023. * // Bound with placeholders.
  11024. * var bound = _.bindKey(object, 'greet', _, '!');
  11025. * bound('hi');
  11026. * // => 'hiya fred!'
  11027. */
  11028. var bindKey = baseRest(function(object, key, partials) {
  11029. var bitmask = WRAP_BIND_FLAG | WRAP_BIND_KEY_FLAG;
  11030. if (partials.length) {
  11031. var holders = replaceHolders(partials, getHolder(bindKey));
  11032. bitmask |= WRAP_PARTIAL_FLAG;
  11033. }
  11034. return createWrap(key, bitmask, object, partials, holders);
  11035. });
  11036. /**
  11037. * Creates a function that accepts arguments of `func` and either invokes
  11038. * `func` returning its result, if at least `arity` number of arguments have
  11039. * been provided, or returns a function that accepts the remaining `func`
  11040. * arguments, and so on. The arity of `func` may be specified if `func.length`
  11041. * is not sufficient.
  11042. *
  11043. * The `_.curry.placeholder` value, which defaults to `_` in monolithic builds,
  11044. * may be used as a placeholder for provided arguments.
  11045. *
  11046. * **Note:** This method doesn't set the "length" property of curried functions.
  11047. *
  11048. * @static
  11049. * @memberOf _
  11050. * @since 2.0.0
  11051. * @category Function
  11052. * @param {Function} func The function to curry.
  11053. * @param {number} [arity=func.length] The arity of `func`.
  11054. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  11055. * @returns {Function} Returns the new curried function.
  11056. * @example
  11057. *
  11058. * var abc = function(a, b, c) {
  11059. * return [a, b, c];
  11060. * };
  11061. *
  11062. * var curried = _.curry(abc);
  11063. *
  11064. * curried(1)(2)(3);
  11065. * // => [1, 2, 3]
  11066. *
  11067. * curried(1, 2)(3);
  11068. * // => [1, 2, 3]
  11069. *
  11070. * curried(1, 2, 3);
  11071. * // => [1, 2, 3]
  11072. *
  11073. * // Curried with placeholders.
  11074. * curried(1)(_, 3)(2);
  11075. * // => [1, 2, 3]
  11076. */
  11077. function curry(func, arity, guard) {
  11078. arity = guard ? undefined : arity;
  11079. var result = createWrap(func, WRAP_CURRY_FLAG, undefined, undefined, undefined, undefined, undefined, arity);
  11080. result.placeholder = curry.placeholder;
  11081. return result;
  11082. }
  11083. /**
  11084. * This method is like `_.curry` except that arguments are applied to `func`
  11085. * in the manner of `_.partialRight` instead of `_.partial`.
  11086. *
  11087. * The `_.curryRight.placeholder` value, which defaults to `_` in monolithic
  11088. * builds, may be used as a placeholder for provided arguments.
  11089. *
  11090. * **Note:** This method doesn't set the "length" property of curried functions.
  11091. *
  11092. * @static
  11093. * @memberOf _
  11094. * @since 3.0.0
  11095. * @category Function
  11096. * @param {Function} func The function to curry.
  11097. * @param {number} [arity=func.length] The arity of `func`.
  11098. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  11099. * @returns {Function} Returns the new curried function.
  11100. * @example
  11101. *
  11102. * var abc = function(a, b, c) {
  11103. * return [a, b, c];
  11104. * };
  11105. *
  11106. * var curried = _.curryRight(abc);
  11107. *
  11108. * curried(3)(2)(1);
  11109. * // => [1, 2, 3]
  11110. *
  11111. * curried(2, 3)(1);
  11112. * // => [1, 2, 3]
  11113. *
  11114. * curried(1, 2, 3);
  11115. * // => [1, 2, 3]
  11116. *
  11117. * // Curried with placeholders.
  11118. * curried(3)(1, _)(2);
  11119. * // => [1, 2, 3]
  11120. */
  11121. function curryRight(func, arity, guard) {
  11122. arity = guard ? undefined : arity;
  11123. var result = createWrap(func, WRAP_CURRY_RIGHT_FLAG, undefined, undefined, undefined, undefined, undefined, arity);
  11124. result.placeholder = curryRight.placeholder;
  11125. return result;
  11126. }
  11127. /**
  11128. * Creates a debounced function that delays invoking `func` until after `wait`
  11129. * milliseconds have elapsed since the last time the debounced function was
  11130. * invoked. The debounced function comes with a `cancel` method to cancel
  11131. * delayed `func` invocations and a `flush` method to immediately invoke them.
  11132. * Provide `options` to indicate whether `func` should be invoked on the
  11133. * leading and/or trailing edge of the `wait` timeout. The `func` is invoked
  11134. * with the last arguments provided to the debounced function. Subsequent
  11135. * calls to the debounced function return the result of the last `func`
  11136. * invocation.
  11137. *
  11138. * **Note:** If `leading` and `trailing` options are `true`, `func` is
  11139. * invoked on the trailing edge of the timeout only if the debounced function
  11140. * is invoked more than once during the `wait` timeout.
  11141. *
  11142. * If `wait` is `0` and `leading` is `false`, `func` invocation is deferred
  11143. * until to the next tick, similar to `setTimeout` with a timeout of `0`.
  11144. *
  11145. * See [David Corbacho's article](https://css-tricks.com/debouncing-throttling-explained-examples/)
  11146. * for details over the differences between `_.debounce` and `_.throttle`.
  11147. *
  11148. * @static
  11149. * @memberOf _
  11150. * @since 0.1.0
  11151. * @category Function
  11152. * @param {Function} func The function to debounce.
  11153. * @param {number} [wait=0] The number of milliseconds to delay.
  11154. * @param {Object} [options={}] The options object.
  11155. * @param {boolean} [options.leading=false]
  11156. * Specify invoking on the leading edge of the timeout.
  11157. * @param {number} [options.maxWait]
  11158. * The maximum time `func` is allowed to be delayed before it's invoked.
  11159. * @param {boolean} [options.trailing=true]
  11160. * Specify invoking on the trailing edge of the timeout.
  11161. * @returns {Function} Returns the new debounced function.
  11162. * @example
  11163. *
  11164. * // Avoid costly calculations while the window size is in flux.
  11165. * jQuery(window).on('resize', _.debounce(calculateLayout, 150));
  11166. *
  11167. * // Invoke `sendMail` when clicked, debouncing subsequent calls.
  11168. * jQuery(element).on('click', _.debounce(sendMail, 300, {
  11169. * 'leading': true,
  11170. * 'trailing': false
  11171. * }));
  11172. *
  11173. * // Ensure `batchLog` is invoked once after 1 second of debounced calls.
  11174. * var debounced = _.debounce(batchLog, 250, { 'maxWait': 1000 });
  11175. * var source = new EventSource('/stream');
  11176. * jQuery(source).on('message', debounced);
  11177. *
  11178. * // Cancel the trailing debounced invocation.
  11179. * jQuery(window).on('popstate', debounced.cancel);
  11180. */
  11181. function debounce(func, wait, options) {
  11182. var lastArgs,
  11183. lastThis,
  11184. maxWait,
  11185. result,
  11186. timerId,
  11187. lastCallTime,
  11188. lastInvokeTime = 0,
  11189. leading = false,
  11190. maxing = false,
  11191. trailing = true;
  11192. if (typeof func != 'function') {
  11193. throw new TypeError(FUNC_ERROR_TEXT);
  11194. }
  11195. wait = toNumber(wait) || 0;
  11196. if (isObject(options)) {
  11197. leading = !!options.leading;
  11198. maxing = 'maxWait' in options;
  11199. maxWait = maxing ? nativeMax(toNumber(options.maxWait) || 0, wait) : maxWait;
  11200. trailing = 'trailing' in options ? !!options.trailing : trailing;
  11201. }
  11202. function invokeFunc(time) {
  11203. var args = lastArgs,
  11204. thisArg = lastThis;
  11205. lastArgs = lastThis = undefined;
  11206. lastInvokeTime = time;
  11207. result = func.apply(thisArg, args);
  11208. return result;
  11209. }
  11210. function leadingEdge(time) {
  11211. // Reset any `maxWait` timer.
  11212. lastInvokeTime = time;
  11213. // Start the timer for the trailing edge.
  11214. timerId = setTimeout(timerExpired, wait);
  11215. // Invoke the leading edge.
  11216. return leading ? invokeFunc(time) : result;
  11217. }
  11218. function remainingWait(time) {
  11219. var timeSinceLastCall = time - lastCallTime,
  11220. timeSinceLastInvoke = time - lastInvokeTime,
  11221. timeWaiting = wait - timeSinceLastCall;
  11222. return maxing
  11223. ? nativeMin(timeWaiting, maxWait - timeSinceLastInvoke)
  11224. : timeWaiting;
  11225. }
  11226. function shouldInvoke(time) {
  11227. var timeSinceLastCall = time - lastCallTime,
  11228. timeSinceLastInvoke = time - lastInvokeTime;
  11229. // Either this is the first call, activity has stopped and we're at the
  11230. // trailing edge, the system time has gone backwards and we're treating
  11231. // it as the trailing edge, or we've hit the `maxWait` limit.
  11232. return (lastCallTime === undefined || (timeSinceLastCall >= wait) ||
  11233. (timeSinceLastCall < 0) || (maxing && timeSinceLastInvoke >= maxWait));
  11234. }
  11235. function timerExpired() {
  11236. var time = now();
  11237. if (shouldInvoke(time)) {
  11238. return trailingEdge(time);
  11239. }
  11240. // Restart the timer.
  11241. timerId = setTimeout(timerExpired, remainingWait(time));
  11242. }
  11243. function trailingEdge(time) {
  11244. timerId = undefined;
  11245. // Only invoke if we have `lastArgs` which means `func` has been
  11246. // debounced at least once.
  11247. if (trailing && lastArgs) {
  11248. return invokeFunc(time);
  11249. }
  11250. lastArgs = lastThis = undefined;
  11251. return result;
  11252. }
  11253. function cancel() {
  11254. if (timerId !== undefined) {
  11255. clearTimeout(timerId);
  11256. }
  11257. lastInvokeTime = 0;
  11258. lastArgs = lastCallTime = lastThis = timerId = undefined;
  11259. }
  11260. function flush() {
  11261. return timerId === undefined ? result : trailingEdge(now());
  11262. }
  11263. function debounced() {
  11264. var time = now(),
  11265. isInvoking = shouldInvoke(time);
  11266. lastArgs = arguments;
  11267. lastThis = this;
  11268. lastCallTime = time;
  11269. if (isInvoking) {
  11270. if (timerId === undefined) {
  11271. return leadingEdge(lastCallTime);
  11272. }
  11273. if (maxing) {
  11274. // Handle invocations in a tight loop.
  11275. clearTimeout(timerId);
  11276. timerId = setTimeout(timerExpired, wait);
  11277. return invokeFunc(lastCallTime);
  11278. }
  11279. }
  11280. if (timerId === undefined) {
  11281. timerId = setTimeout(timerExpired, wait);
  11282. }
  11283. return result;
  11284. }
  11285. debounced.cancel = cancel;
  11286. debounced.flush = flush;
  11287. return debounced;
  11288. }
  11289. /**
  11290. * Defers invoking the `func` until the current call stack has cleared. Any
  11291. * additional arguments are provided to `func` when it's invoked.
  11292. *
  11293. * @static
  11294. * @memberOf _
  11295. * @since 0.1.0
  11296. * @category Function
  11297. * @param {Function} func The function to defer.
  11298. * @param {...*} [args] The arguments to invoke `func` with.
  11299. * @returns {number} Returns the timer id.
  11300. * @example
  11301. *
  11302. * _.defer(function(text) {
  11303. * console.log(text);
  11304. * }, 'deferred');
  11305. * // => Logs 'deferred' after one millisecond.
  11306. */
  11307. var defer = baseRest(function(func, args) {
  11308. return baseDelay(func, 1, args);
  11309. });
  11310. /**
  11311. * Invokes `func` after `wait` milliseconds. Any additional arguments are
  11312. * provided to `func` when it's invoked.
  11313. *
  11314. * @static
  11315. * @memberOf _
  11316. * @since 0.1.0
  11317. * @category Function
  11318. * @param {Function} func The function to delay.
  11319. * @param {number} wait The number of milliseconds to delay invocation.
  11320. * @param {...*} [args] The arguments to invoke `func` with.
  11321. * @returns {number} Returns the timer id.
  11322. * @example
  11323. *
  11324. * _.delay(function(text) {
  11325. * console.log(text);
  11326. * }, 1000, 'later');
  11327. * // => Logs 'later' after one second.
  11328. */
  11329. var delay = baseRest(function(func, wait, args) {
  11330. return baseDelay(func, toNumber(wait) || 0, args);
  11331. });
  11332. /**
  11333. * Creates a function that invokes `func` with arguments reversed.
  11334. *
  11335. * @static
  11336. * @memberOf _
  11337. * @since 4.0.0
  11338. * @category Function
  11339. * @param {Function} func The function to flip arguments for.
  11340. * @returns {Function} Returns the new flipped function.
  11341. * @example
  11342. *
  11343. * var flipped = _.flip(function() {
  11344. * return _.toArray(arguments);
  11345. * });
  11346. *
  11347. * flipped('a', 'b', 'c', 'd');
  11348. * // => ['d', 'c', 'b', 'a']
  11349. */
  11350. function flip(func) {
  11351. return createWrap(func, WRAP_FLIP_FLAG);
  11352. }
  11353. /**
  11354. * Creates a function that memoizes the result of `func`. If `resolver` is
  11355. * provided, it determines the cache key for storing the result based on the
  11356. * arguments provided to the memoized function. By default, the first argument
  11357. * provided to the memoized function is used as the map cache key. The `func`
  11358. * is invoked with the `this` binding of the memoized function.
  11359. *
  11360. * **Note:** The cache is exposed as the `cache` property on the memoized
  11361. * function. Its creation may be customized by replacing the `_.memoize.Cache`
  11362. * constructor with one whose instances implement the
  11363. * [`Map`](http://ecma-international.org/ecma-262/7.0/#sec-properties-of-the-map-prototype-object)
  11364. * method interface of `clear`, `delete`, `get`, `has`, and `set`.
  11365. *
  11366. * @static
  11367. * @memberOf _
  11368. * @since 0.1.0
  11369. * @category Function
  11370. * @param {Function} func The function to have its output memoized.
  11371. * @param {Function} [resolver] The function to resolve the cache key.
  11372. * @returns {Function} Returns the new memoized function.
  11373. * @example
  11374. *
  11375. * var object = { 'a': 1, 'b': 2 };
  11376. * var other = { 'c': 3, 'd': 4 };
  11377. *
  11378. * var values = _.memoize(_.values);
  11379. * values(object);
  11380. * // => [1, 2]
  11381. *
  11382. * values(other);
  11383. * // => [3, 4]
  11384. *
  11385. * object.a = 2;
  11386. * values(object);
  11387. * // => [1, 2]
  11388. *
  11389. * // Modify the result cache.
  11390. * values.cache.set(object, ['a', 'b']);
  11391. * values(object);
  11392. * // => ['a', 'b']
  11393. *
  11394. * // Replace `_.memoize.Cache`.
  11395. * _.memoize.Cache = WeakMap;
  11396. */
  11397. function memoize(func, resolver) {
  11398. if (typeof func != 'function' || (resolver != null && typeof resolver != 'function')) {
  11399. throw new TypeError(FUNC_ERROR_TEXT);
  11400. }
  11401. var memoized = function() {
  11402. var args = arguments,
  11403. key = resolver ? resolver.apply(this, args) : args[0],
  11404. cache = memoized.cache;
  11405. if (cache.has(key)) {
  11406. return cache.get(key);
  11407. }
  11408. var result = func.apply(this, args);
  11409. memoized.cache = cache.set(key, result) || cache;
  11410. return result;
  11411. };
  11412. memoized.cache = new (memoize.Cache || MapCache);
  11413. return memoized;
  11414. }
  11415. // Expose `MapCache`.
  11416. memoize.Cache = MapCache;
  11417. /**
  11418. * Creates a function that negates the result of the predicate `func`. The
  11419. * `func` predicate is invoked with the `this` binding and arguments of the
  11420. * created function.
  11421. *
  11422. * @static
  11423. * @memberOf _
  11424. * @since 3.0.0
  11425. * @category Function
  11426. * @param {Function} predicate The predicate to negate.
  11427. * @returns {Function} Returns the new negated function.
  11428. * @example
  11429. *
  11430. * function isEven(n) {
  11431. * return n % 2 == 0;
  11432. * }
  11433. *
  11434. * _.filter([1, 2, 3, 4, 5, 6], _.negate(isEven));
  11435. * // => [1, 3, 5]
  11436. */
  11437. function negate(predicate) {
  11438. if (typeof predicate != 'function') {
  11439. throw new TypeError(FUNC_ERROR_TEXT);
  11440. }
  11441. return function() {
  11442. var args = arguments;
  11443. switch (args.length) {
  11444. case 0: return !predicate.call(this);
  11445. case 1: return !predicate.call(this, args[0]);
  11446. case 2: return !predicate.call(this, args[0], args[1]);
  11447. case 3: return !predicate.call(this, args[0], args[1], args[2]);
  11448. }
  11449. return !predicate.apply(this, args);
  11450. };
  11451. }
  11452. /**
  11453. * Creates a function that is restricted to invoking `func` once. Repeat calls
  11454. * to the function return the value of the first invocation. The `func` is
  11455. * invoked with the `this` binding and arguments of the created function.
  11456. *
  11457. * @static
  11458. * @memberOf _
  11459. * @since 0.1.0
  11460. * @category Function
  11461. * @param {Function} func The function to restrict.
  11462. * @returns {Function} Returns the new restricted function.
  11463. * @example
  11464. *
  11465. * var initialize = _.once(createApplication);
  11466. * initialize();
  11467. * initialize();
  11468. * // => `createApplication` is invoked once
  11469. */
  11470. function once(func) {
  11471. return before(2, func);
  11472. }
  11473. /**
  11474. * Creates a function that invokes `func` with its arguments transformed.
  11475. *
  11476. * @static
  11477. * @since 4.0.0
  11478. * @memberOf _
  11479. * @category Function
  11480. * @param {Function} func The function to wrap.
  11481. * @param {...(Function|Function[])} [transforms=[_.identity]]
  11482. * The argument transforms.
  11483. * @returns {Function} Returns the new function.
  11484. * @example
  11485. *
  11486. * function doubled(n) {
  11487. * return n * 2;
  11488. * }
  11489. *
  11490. * function square(n) {
  11491. * return n * n;
  11492. * }
  11493. *
  11494. * var func = _.overArgs(function(x, y) {
  11495. * return [x, y];
  11496. * }, [square, doubled]);
  11497. *
  11498. * func(9, 3);
  11499. * // => [81, 6]
  11500. *
  11501. * func(10, 5);
  11502. * // => [100, 10]
  11503. */
  11504. var overArgs = castRest(function(func, transforms) {
  11505. transforms = (transforms.length == 1 && isArray(transforms[0]))
  11506. ? arrayMap(transforms[0], baseUnary(getIteratee()))
  11507. : arrayMap(baseFlatten(transforms, 1), baseUnary(getIteratee()));
  11508. var funcsLength = transforms.length;
  11509. return baseRest(function(args) {
  11510. var index = -1,
  11511. length = nativeMin(args.length, funcsLength);
  11512. while (++index < length) {
  11513. args[index] = transforms[index].call(this, args[index]);
  11514. }
  11515. return apply(func, this, args);
  11516. });
  11517. });
  11518. /**
  11519. * Creates a function that invokes `func` with `partials` prepended to the
  11520. * arguments it receives. This method is like `_.bind` except it does **not**
  11521. * alter the `this` binding.
  11522. *
  11523. * The `_.partial.placeholder` value, which defaults to `_` in monolithic
  11524. * builds, may be used as a placeholder for partially applied arguments.
  11525. *
  11526. * **Note:** This method doesn't set the "length" property of partially
  11527. * applied functions.
  11528. *
  11529. * @static
  11530. * @memberOf _
  11531. * @since 0.2.0
  11532. * @category Function
  11533. * @param {Function} func The function to partially apply arguments to.
  11534. * @param {...*} [partials] The arguments to be partially applied.
  11535. * @returns {Function} Returns the new partially applied function.
  11536. * @example
  11537. *
  11538. * function greet(greeting, name) {
  11539. * return greeting + ' ' + name;
  11540. * }
  11541. *
  11542. * var sayHelloTo = _.partial(greet, 'hello');
  11543. * sayHelloTo('fred');
  11544. * // => 'hello fred'
  11545. *
  11546. * // Partially applied with placeholders.
  11547. * var greetFred = _.partial(greet, _, 'fred');
  11548. * greetFred('hi');
  11549. * // => 'hi fred'
  11550. */
  11551. var partial = baseRest(function(func, partials) {
  11552. var holders = replaceHolders(partials, getHolder(partial));
  11553. return createWrap(func, WRAP_PARTIAL_FLAG, undefined, partials, holders);
  11554. });
  11555. /**
  11556. * This method is like `_.partial` except that partially applied arguments
  11557. * are appended to the arguments it receives.
  11558. *
  11559. * The `_.partialRight.placeholder` value, which defaults to `_` in monolithic
  11560. * builds, may be used as a placeholder for partially applied arguments.
  11561. *
  11562. * **Note:** This method doesn't set the "length" property of partially
  11563. * applied functions.
  11564. *
  11565. * @static
  11566. * @memberOf _
  11567. * @since 1.0.0
  11568. * @category Function
  11569. * @param {Function} func The function to partially apply arguments to.
  11570. * @param {...*} [partials] The arguments to be partially applied.
  11571. * @returns {Function} Returns the new partially applied function.
  11572. * @example
  11573. *
  11574. * function greet(greeting, name) {
  11575. * return greeting + ' ' + name;
  11576. * }
  11577. *
  11578. * var greetFred = _.partialRight(greet, 'fred');
  11579. * greetFred('hi');
  11580. * // => 'hi fred'
  11581. *
  11582. * // Partially applied with placeholders.
  11583. * var sayHelloTo = _.partialRight(greet, 'hello', _);
  11584. * sayHelloTo('fred');
  11585. * // => 'hello fred'
  11586. */
  11587. var partialRight = baseRest(function(func, partials) {
  11588. var holders = replaceHolders(partials, getHolder(partialRight));
  11589. return createWrap(func, WRAP_PARTIAL_RIGHT_FLAG, undefined, partials, holders);
  11590. });
  11591. /**
  11592. * Creates a function that invokes `func` with arguments arranged according
  11593. * to the specified `indexes` where the argument value at the first index is
  11594. * provided as the first argument, the argument value at the second index is
  11595. * provided as the second argument, and so on.
  11596. *
  11597. * @static
  11598. * @memberOf _
  11599. * @since 3.0.0
  11600. * @category Function
  11601. * @param {Function} func The function to rearrange arguments for.
  11602. * @param {...(number|number[])} indexes The arranged argument indexes.
  11603. * @returns {Function} Returns the new function.
  11604. * @example
  11605. *
  11606. * var rearged = _.rearg(function(a, b, c) {
  11607. * return [a, b, c];
  11608. * }, [2, 0, 1]);
  11609. *
  11610. * rearged('b', 'c', 'a')
  11611. * // => ['a', 'b', 'c']
  11612. */
  11613. var rearg = flatRest(function(func, indexes) {
  11614. return createWrap(func, WRAP_REARG_FLAG, undefined, undefined, undefined, indexes);
  11615. });
  11616. /**
  11617. * Creates a function that invokes `func` with the `this` binding of the
  11618. * created function and arguments from `start` and beyond provided as
  11619. * an array.
  11620. *
  11621. * **Note:** This method is based on the
  11622. * [rest parameter](https://mdn.io/rest_parameters).
  11623. *
  11624. * @static
  11625. * @memberOf _
  11626. * @since 4.0.0
  11627. * @category Function
  11628. * @param {Function} func The function to apply a rest parameter to.
  11629. * @param {number} [start=func.length-1] The start position of the rest parameter.
  11630. * @returns {Function} Returns the new function.
  11631. * @example
  11632. *
  11633. * var say = _.rest(function(what, names) {
  11634. * return what + ' ' + _.initial(names).join(', ') +
  11635. * (_.size(names) > 1 ? ', & ' : '') + _.last(names);
  11636. * });
  11637. *
  11638. * say('hello', 'fred', 'barney', 'pebbles');
  11639. * // => 'hello fred, barney, & pebbles'
  11640. */
  11641. function rest(func, start) {
  11642. if (typeof func != 'function') {
  11643. throw new TypeError(FUNC_ERROR_TEXT);
  11644. }
  11645. start = start === undefined ? start : toInteger(start);
  11646. return baseRest(func, start);
  11647. }
  11648. /**
  11649. * Creates a function that invokes `func` with the `this` binding of the
  11650. * create function and an array of arguments much like
  11651. * [`Function#apply`](http://www.ecma-international.org/ecma-262/7.0/#sec-function.prototype.apply).
  11652. *
  11653. * **Note:** This method is based on the
  11654. * [spread operator](https://mdn.io/spread_operator).
  11655. *
  11656. * @static
  11657. * @memberOf _
  11658. * @since 3.2.0
  11659. * @category Function
  11660. * @param {Function} func The function to spread arguments over.
  11661. * @param {number} [start=0] The start position of the spread.
  11662. * @returns {Function} Returns the new function.
  11663. * @example
  11664. *
  11665. * var say = _.spread(function(who, what) {
  11666. * return who + ' says ' + what;
  11667. * });
  11668. *
  11669. * say(['fred', 'hello']);
  11670. * // => 'fred says hello'
  11671. *
  11672. * var numbers = Promise.all([
  11673. * Promise.resolve(40),
  11674. * Promise.resolve(36)
  11675. * ]);
  11676. *
  11677. * numbers.then(_.spread(function(x, y) {
  11678. * return x + y;
  11679. * }));
  11680. * // => a Promise of 76
  11681. */
  11682. function spread(func, start) {
  11683. if (typeof func != 'function') {
  11684. throw new TypeError(FUNC_ERROR_TEXT);
  11685. }
  11686. start = start == null ? 0 : nativeMax(toInteger(start), 0);
  11687. return baseRest(function(args) {
  11688. var array = args[start],
  11689. otherArgs = castSlice(args, 0, start);
  11690. if (array) {
  11691. arrayPush(otherArgs, array);
  11692. }
  11693. return apply(func, this, otherArgs);
  11694. });
  11695. }
  11696. /**
  11697. * Creates a throttled function that only invokes `func` at most once per
  11698. * every `wait` milliseconds. The throttled function comes with a `cancel`
  11699. * method to cancel delayed `func` invocations and a `flush` method to
  11700. * immediately invoke them. Provide `options` to indicate whether `func`
  11701. * should be invoked on the leading and/or trailing edge of the `wait`
  11702. * timeout. The `func` is invoked with the last arguments provided to the
  11703. * throttled function. Subsequent calls to the throttled function return the
  11704. * result of the last `func` invocation.
  11705. *
  11706. * **Note:** If `leading` and `trailing` options are `true`, `func` is
  11707. * invoked on the trailing edge of the timeout only if the throttled function
  11708. * is invoked more than once during the `wait` timeout.
  11709. *
  11710. * If `wait` is `0` and `leading` is `false`, `func` invocation is deferred
  11711. * until to the next tick, similar to `setTimeout` with a timeout of `0`.
  11712. *
  11713. * See [David Corbacho's article](https://css-tricks.com/debouncing-throttling-explained-examples/)
  11714. * for details over the differences between `_.throttle` and `_.debounce`.
  11715. *
  11716. * @static
  11717. * @memberOf _
  11718. * @since 0.1.0
  11719. * @category Function
  11720. * @param {Function} func The function to throttle.
  11721. * @param {number} [wait=0] The number of milliseconds to throttle invocations to.
  11722. * @param {Object} [options={}] The options object.
  11723. * @param {boolean} [options.leading=true]
  11724. * Specify invoking on the leading edge of the timeout.
  11725. * @param {boolean} [options.trailing=true]
  11726. * Specify invoking on the trailing edge of the timeout.
  11727. * @returns {Function} Returns the new throttled function.
  11728. * @example
  11729. *
  11730. * // Avoid excessively updating the position while scrolling.
  11731. * jQuery(window).on('scroll', _.throttle(updatePosition, 100));
  11732. *
  11733. * // Invoke `renewToken` when the click event is fired, but not more than once every 5 minutes.
  11734. * var throttled = _.throttle(renewToken, 300000, { 'trailing': false });
  11735. * jQuery(element).on('click', throttled);
  11736. *
  11737. * // Cancel the trailing throttled invocation.
  11738. * jQuery(window).on('popstate', throttled.cancel);
  11739. */
  11740. function throttle(func, wait, options) {
  11741. var leading = true,
  11742. trailing = true;
  11743. if (typeof func != 'function') {
  11744. throw new TypeError(FUNC_ERROR_TEXT);
  11745. }
  11746. if (isObject(options)) {
  11747. leading = 'leading' in options ? !!options.leading : leading;
  11748. trailing = 'trailing' in options ? !!options.trailing : trailing;
  11749. }
  11750. return debounce(func, wait, {
  11751. 'leading': leading,
  11752. 'maxWait': wait,
  11753. 'trailing': trailing
  11754. });
  11755. }
  11756. /**
  11757. * Creates a function that accepts up to one argument, ignoring any
  11758. * additional arguments.
  11759. *
  11760. * @static
  11761. * @memberOf _
  11762. * @since 4.0.0
  11763. * @category Function
  11764. * @param {Function} func The function to cap arguments for.
  11765. * @returns {Function} Returns the new capped function.
  11766. * @example
  11767. *
  11768. * _.map(['6', '8', '10'], _.unary(parseInt));
  11769. * // => [6, 8, 10]
  11770. */
  11771. function unary(func) {
  11772. return ary(func, 1);
  11773. }
  11774. /**
  11775. * Creates a function that provides `value` to `wrapper` as its first
  11776. * argument. Any additional arguments provided to the function are appended
  11777. * to those provided to the `wrapper`. The wrapper is invoked with the `this`
  11778. * binding of the created function.
  11779. *
  11780. * @static
  11781. * @memberOf _
  11782. * @since 0.1.0
  11783. * @category Function
  11784. * @param {*} value The value to wrap.
  11785. * @param {Function} [wrapper=identity] The wrapper function.
  11786. * @returns {Function} Returns the new function.
  11787. * @example
  11788. *
  11789. * var p = _.wrap(_.escape, function(func, text) {
  11790. * return '<p>' + func(text) + '</p>';
  11791. * });
  11792. *
  11793. * p('fred, barney, & pebbles');
  11794. * // => '<p>fred, barney, &amp; pebbles</p>'
  11795. */
  11796. function wrap(value, wrapper) {
  11797. return partial(castFunction(wrapper), value);
  11798. }
  11799. /*------------------------------------------------------------------------*/
  11800. /**
  11801. * Casts `value` as an array if it's not one.
  11802. *
  11803. * @static
  11804. * @memberOf _
  11805. * @since 4.4.0
  11806. * @category Lang
  11807. * @param {*} value The value to inspect.
  11808. * @returns {Array} Returns the cast array.
  11809. * @example
  11810. *
  11811. * _.castArray(1);
  11812. * // => [1]
  11813. *
  11814. * _.castArray({ 'a': 1 });
  11815. * // => [{ 'a': 1 }]
  11816. *
  11817. * _.castArray('abc');
  11818. * // => ['abc']
  11819. *
  11820. * _.castArray(null);
  11821. * // => [null]
  11822. *
  11823. * _.castArray(undefined);
  11824. * // => [undefined]
  11825. *
  11826. * _.castArray();
  11827. * // => []
  11828. *
  11829. * var array = [1, 2, 3];
  11830. * console.log(_.castArray(array) === array);
  11831. * // => true
  11832. */
  11833. function castArray() {
  11834. if (!arguments.length) {
  11835. return [];
  11836. }
  11837. var value = arguments[0];
  11838. return isArray(value) ? value : [value];
  11839. }
  11840. /**
  11841. * Creates a shallow clone of `value`.
  11842. *
  11843. * **Note:** This method is loosely based on the
  11844. * [structured clone algorithm](https://mdn.io/Structured_clone_algorithm)
  11845. * and supports cloning arrays, array buffers, booleans, date objects, maps,
  11846. * numbers, `Object` objects, regexes, sets, strings, symbols, and typed
  11847. * arrays. The own enumerable properties of `arguments` objects are cloned
  11848. * as plain objects. An empty object is returned for uncloneable values such
  11849. * as error objects, functions, DOM nodes, and WeakMaps.
  11850. *
  11851. * @static
  11852. * @memberOf _
  11853. * @since 0.1.0
  11854. * @category Lang
  11855. * @param {*} value The value to clone.
  11856. * @returns {*} Returns the cloned value.
  11857. * @see _.cloneDeep
  11858. * @example
  11859. *
  11860. * var objects = [{ 'a': 1 }, { 'b': 2 }];
  11861. *
  11862. * var shallow = _.clone(objects);
  11863. * console.log(shallow[0] === objects[0]);
  11864. * // => true
  11865. */
  11866. function clone(value) {
  11867. return baseClone(value, CLONE_SYMBOLS_FLAG);
  11868. }
  11869. /**
  11870. * This method is like `_.clone` except that it accepts `customizer` which
  11871. * is invoked to produce the cloned value. If `customizer` returns `undefined`,
  11872. * cloning is handled by the method instead. The `customizer` is invoked with
  11873. * up to four arguments; (value [, index|key, object, stack]).
  11874. *
  11875. * @static
  11876. * @memberOf _
  11877. * @since 4.0.0
  11878. * @category Lang
  11879. * @param {*} value The value to clone.
  11880. * @param {Function} [customizer] The function to customize cloning.
  11881. * @returns {*} Returns the cloned value.
  11882. * @see _.cloneDeepWith
  11883. * @example
  11884. *
  11885. * function customizer(value) {
  11886. * if (_.isElement(value)) {
  11887. * return value.cloneNode(false);
  11888. * }
  11889. * }
  11890. *
  11891. * var el = _.cloneWith(document.body, customizer);
  11892. *
  11893. * console.log(el === document.body);
  11894. * // => false
  11895. * console.log(el.nodeName);
  11896. * // => 'BODY'
  11897. * console.log(el.childNodes.length);
  11898. * // => 0
  11899. */
  11900. function cloneWith(value, customizer) {
  11901. customizer = typeof customizer == 'function' ? customizer : undefined;
  11902. return baseClone(value, CLONE_SYMBOLS_FLAG, customizer);
  11903. }
  11904. /**
  11905. * This method is like `_.clone` except that it recursively clones `value`.
  11906. *
  11907. * @static
  11908. * @memberOf _
  11909. * @since 1.0.0
  11910. * @category Lang
  11911. * @param {*} value The value to recursively clone.
  11912. * @returns {*} Returns the deep cloned value.
  11913. * @see _.clone
  11914. * @example
  11915. *
  11916. * var objects = [{ 'a': 1 }, { 'b': 2 }];
  11917. *
  11918. * var deep = _.cloneDeep(objects);
  11919. * console.log(deep[0] === objects[0]);
  11920. * // => false
  11921. */
  11922. function cloneDeep(value) {
  11923. return baseClone(value, CLONE_DEEP_FLAG | CLONE_SYMBOLS_FLAG);
  11924. }
  11925. /**
  11926. * This method is like `_.cloneWith` except that it recursively clones `value`.
  11927. *
  11928. * @static
  11929. * @memberOf _
  11930. * @since 4.0.0
  11931. * @category Lang
  11932. * @param {*} value The value to recursively clone.
  11933. * @param {Function} [customizer] The function to customize cloning.
  11934. * @returns {*} Returns the deep cloned value.
  11935. * @see _.cloneWith
  11936. * @example
  11937. *
  11938. * function customizer(value) {
  11939. * if (_.isElement(value)) {
  11940. * return value.cloneNode(true);
  11941. * }
  11942. * }
  11943. *
  11944. * var el = _.cloneDeepWith(document.body, customizer);
  11945. *
  11946. * console.log(el === document.body);
  11947. * // => false
  11948. * console.log(el.nodeName);
  11949. * // => 'BODY'
  11950. * console.log(el.childNodes.length);
  11951. * // => 20
  11952. */
  11953. function cloneDeepWith(value, customizer) {
  11954. customizer = typeof customizer == 'function' ? customizer : undefined;
  11955. return baseClone(value, CLONE_DEEP_FLAG | CLONE_SYMBOLS_FLAG, customizer);
  11956. }
  11957. /**
  11958. * Checks if `object` conforms to `source` by invoking the predicate
  11959. * properties of `source` with the corresponding property values of `object`.
  11960. *
  11961. * **Note:** This method is equivalent to `_.conforms` when `source` is
  11962. * partially applied.
  11963. *
  11964. * @static
  11965. * @memberOf _
  11966. * @since 4.14.0
  11967. * @category Lang
  11968. * @param {Object} object The object to inspect.
  11969. * @param {Object} source The object of property predicates to conform to.
  11970. * @returns {boolean} Returns `true` if `object` conforms, else `false`.
  11971. * @example
  11972. *
  11973. * var object = { 'a': 1, 'b': 2 };
  11974. *
  11975. * _.conformsTo(object, { 'b': function(n) { return n > 1; } });
  11976. * // => true
  11977. *
  11978. * _.conformsTo(object, { 'b': function(n) { return n > 2; } });
  11979. * // => false
  11980. */
  11981. function conformsTo(object, source) {
  11982. return source == null || baseConformsTo(object, source, keys(source));
  11983. }
  11984. /**
  11985. * Performs a
  11986. * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
  11987. * comparison between two values to determine if they are equivalent.
  11988. *
  11989. * @static
  11990. * @memberOf _
  11991. * @since 4.0.0
  11992. * @category Lang
  11993. * @param {*} value The value to compare.
  11994. * @param {*} other The other value to compare.
  11995. * @returns {boolean} Returns `true` if the values are equivalent, else `false`.
  11996. * @example
  11997. *
  11998. * var object = { 'a': 1 };
  11999. * var other = { 'a': 1 };
  12000. *
  12001. * _.eq(object, object);
  12002. * // => true
  12003. *
  12004. * _.eq(object, other);
  12005. * // => false
  12006. *
  12007. * _.eq('a', 'a');
  12008. * // => true
  12009. *
  12010. * _.eq('a', Object('a'));
  12011. * // => false
  12012. *
  12013. * _.eq(NaN, NaN);
  12014. * // => true
  12015. */
  12016. function eq(value, other) {
  12017. return value === other || (value !== value && other !== other);
  12018. }
  12019. /**
  12020. * Checks if `value` is greater than `other`.
  12021. *
  12022. * @static
  12023. * @memberOf _
  12024. * @since 3.9.0
  12025. * @category Lang
  12026. * @param {*} value The value to compare.
  12027. * @param {*} other The other value to compare.
  12028. * @returns {boolean} Returns `true` if `value` is greater than `other`,
  12029. * else `false`.
  12030. * @see _.lt
  12031. * @example
  12032. *
  12033. * _.gt(3, 1);
  12034. * // => true
  12035. *
  12036. * _.gt(3, 3);
  12037. * // => false
  12038. *
  12039. * _.gt(1, 3);
  12040. * // => false
  12041. */
  12042. var gt = createRelationalOperation(baseGt);
  12043. /**
  12044. * Checks if `value` is greater than or equal to `other`.
  12045. *
  12046. * @static
  12047. * @memberOf _
  12048. * @since 3.9.0
  12049. * @category Lang
  12050. * @param {*} value The value to compare.
  12051. * @param {*} other The other value to compare.
  12052. * @returns {boolean} Returns `true` if `value` is greater than or equal to
  12053. * `other`, else `false`.
  12054. * @see _.lte
  12055. * @example
  12056. *
  12057. * _.gte(3, 1);
  12058. * // => true
  12059. *
  12060. * _.gte(3, 3);
  12061. * // => true
  12062. *
  12063. * _.gte(1, 3);
  12064. * // => false
  12065. */
  12066. var gte = createRelationalOperation(function(value, other) {
  12067. return value >= other;
  12068. });
  12069. /**
  12070. * Checks if `value` is likely an `arguments` object.
  12071. *
  12072. * @static
  12073. * @memberOf _
  12074. * @since 0.1.0
  12075. * @category Lang
  12076. * @param {*} value The value to check.
  12077. * @returns {boolean} Returns `true` if `value` is an `arguments` object,
  12078. * else `false`.
  12079. * @example
  12080. *
  12081. * _.isArguments(function() { return arguments; }());
  12082. * // => true
  12083. *
  12084. * _.isArguments([1, 2, 3]);
  12085. * // => false
  12086. */
  12087. var isArguments = baseIsArguments(function() { return arguments; }()) ? baseIsArguments : function(value) {
  12088. return isObjectLike(value) && hasOwnProperty.call(value, 'callee') &&
  12089. !propertyIsEnumerable.call(value, 'callee');
  12090. };
  12091. /**
  12092. * Checks if `value` is classified as an `Array` object.
  12093. *
  12094. * @static
  12095. * @memberOf _
  12096. * @since 0.1.0
  12097. * @category Lang
  12098. * @param {*} value The value to check.
  12099. * @returns {boolean} Returns `true` if `value` is an array, else `false`.
  12100. * @example
  12101. *
  12102. * _.isArray([1, 2, 3]);
  12103. * // => true
  12104. *
  12105. * _.isArray(document.body.children);
  12106. * // => false
  12107. *
  12108. * _.isArray('abc');
  12109. * // => false
  12110. *
  12111. * _.isArray(_.noop);
  12112. * // => false
  12113. */
  12114. var isArray = Array.isArray;
  12115. /**
  12116. * Checks if `value` is classified as an `ArrayBuffer` object.
  12117. *
  12118. * @static
  12119. * @memberOf _
  12120. * @since 4.3.0
  12121. * @category Lang
  12122. * @param {*} value The value to check.
  12123. * @returns {boolean} Returns `true` if `value` is an array buffer, else `false`.
  12124. * @example
  12125. *
  12126. * _.isArrayBuffer(new ArrayBuffer(2));
  12127. * // => true
  12128. *
  12129. * _.isArrayBuffer(new Array(2));
  12130. * // => false
  12131. */
  12132. var isArrayBuffer = nodeIsArrayBuffer ? baseUnary(nodeIsArrayBuffer) : baseIsArrayBuffer;
  12133. /**
  12134. * Checks if `value` is array-like. A value is considered array-like if it's
  12135. * not a function and has a `value.length` that's an integer greater than or
  12136. * equal to `0` and less than or equal to `Number.MAX_SAFE_INTEGER`.
  12137. *
  12138. * @static
  12139. * @memberOf _
  12140. * @since 4.0.0
  12141. * @category Lang
  12142. * @param {*} value The value to check.
  12143. * @returns {boolean} Returns `true` if `value` is array-like, else `false`.
  12144. * @example
  12145. *
  12146. * _.isArrayLike([1, 2, 3]);
  12147. * // => true
  12148. *
  12149. * _.isArrayLike(document.body.children);
  12150. * // => true
  12151. *
  12152. * _.isArrayLike('abc');
  12153. * // => true
  12154. *
  12155. * _.isArrayLike(_.noop);
  12156. * // => false
  12157. */
  12158. function isArrayLike(value) {
  12159. return value != null && isLength(value.length) && !isFunction(value);
  12160. }
  12161. /**
  12162. * This method is like `_.isArrayLike` except that it also checks if `value`
  12163. * is an object.
  12164. *
  12165. * @static
  12166. * @memberOf _
  12167. * @since 4.0.0
  12168. * @category Lang
  12169. * @param {*} value The value to check.
  12170. * @returns {boolean} Returns `true` if `value` is an array-like object,
  12171. * else `false`.
  12172. * @example
  12173. *
  12174. * _.isArrayLikeObject([1, 2, 3]);
  12175. * // => true
  12176. *
  12177. * _.isArrayLikeObject(document.body.children);
  12178. * // => true
  12179. *
  12180. * _.isArrayLikeObject('abc');
  12181. * // => false
  12182. *
  12183. * _.isArrayLikeObject(_.noop);
  12184. * // => false
  12185. */
  12186. function isArrayLikeObject(value) {
  12187. return isObjectLike(value) && isArrayLike(value);
  12188. }
  12189. /**
  12190. * Checks if `value` is classified as a boolean primitive or object.
  12191. *
  12192. * @static
  12193. * @memberOf _
  12194. * @since 0.1.0
  12195. * @category Lang
  12196. * @param {*} value The value to check.
  12197. * @returns {boolean} Returns `true` if `value` is a boolean, else `false`.
  12198. * @example
  12199. *
  12200. * _.isBoolean(false);
  12201. * // => true
  12202. *
  12203. * _.isBoolean(null);
  12204. * // => false
  12205. */
  12206. function isBoolean(value) {
  12207. return value === true || value === false ||
  12208. (isObjectLike(value) && baseGetTag(value) == boolTag);
  12209. }
  12210. /**
  12211. * Checks if `value` is a buffer.
  12212. *
  12213. * @static
  12214. * @memberOf _
  12215. * @since 4.3.0
  12216. * @category Lang
  12217. * @param {*} value The value to check.
  12218. * @returns {boolean} Returns `true` if `value` is a buffer, else `false`.
  12219. * @example
  12220. *
  12221. * _.isBuffer(new Buffer(2));
  12222. * // => true
  12223. *
  12224. * _.isBuffer(new Uint8Array(2));
  12225. * // => false
  12226. */
  12227. var isBuffer = nativeIsBuffer || stubFalse;
  12228. /**
  12229. * Checks if `value` is classified as a `Date` object.
  12230. *
  12231. * @static
  12232. * @memberOf _
  12233. * @since 0.1.0
  12234. * @category Lang
  12235. * @param {*} value The value to check.
  12236. * @returns {boolean} Returns `true` if `value` is a date object, else `false`.
  12237. * @example
  12238. *
  12239. * _.isDate(new Date);
  12240. * // => true
  12241. *
  12242. * _.isDate('Mon April 23 2012');
  12243. * // => false
  12244. */
  12245. var isDate = nodeIsDate ? baseUnary(nodeIsDate) : baseIsDate;
  12246. /**
  12247. * Checks if `value` is likely a DOM element.
  12248. *
  12249. * @static
  12250. * @memberOf _
  12251. * @since 0.1.0
  12252. * @category Lang
  12253. * @param {*} value The value to check.
  12254. * @returns {boolean} Returns `true` if `value` is a DOM element, else `false`.
  12255. * @example
  12256. *
  12257. * _.isElement(document.body);
  12258. * // => true
  12259. *
  12260. * _.isElement('<body>');
  12261. * // => false
  12262. */
  12263. function isElement(value) {
  12264. return isObjectLike(value) && value.nodeType === 1 && !isPlainObject(value);
  12265. }
  12266. /**
  12267. * Checks if `value` is an empty object, collection, map, or set.
  12268. *
  12269. * Objects are considered empty if they have no own enumerable string keyed
  12270. * properties.
  12271. *
  12272. * Array-like values such as `arguments` objects, arrays, buffers, strings, or
  12273. * jQuery-like collections are considered empty if they have a `length` of `0`.
  12274. * Similarly, maps and sets are considered empty if they have a `size` of `0`.
  12275. *
  12276. * @static
  12277. * @memberOf _
  12278. * @since 0.1.0
  12279. * @category Lang
  12280. * @param {*} value The value to check.
  12281. * @returns {boolean} Returns `true` if `value` is empty, else `false`.
  12282. * @example
  12283. *
  12284. * _.isEmpty(null);
  12285. * // => true
  12286. *
  12287. * _.isEmpty(true);
  12288. * // => true
  12289. *
  12290. * _.isEmpty(1);
  12291. * // => true
  12292. *
  12293. * _.isEmpty([1, 2, 3]);
  12294. * // => false
  12295. *
  12296. * _.isEmpty({ 'a': 1 });
  12297. * // => false
  12298. */
  12299. function isEmpty(value) {
  12300. if (value == null) {
  12301. return true;
  12302. }
  12303. if (isArrayLike(value) &&
  12304. (isArray(value) || typeof value == 'string' || typeof value.splice == 'function' ||
  12305. isBuffer(value) || isTypedArray(value) || isArguments(value))) {
  12306. return !value.length;
  12307. }
  12308. var tag = getTag(value);
  12309. if (tag == mapTag || tag == setTag) {
  12310. return !value.size;
  12311. }
  12312. if (isPrototype(value)) {
  12313. return !baseKeys(value).length;
  12314. }
  12315. for (var key in value) {
  12316. if (hasOwnProperty.call(value, key)) {
  12317. return false;
  12318. }
  12319. }
  12320. return true;
  12321. }
  12322. /**
  12323. * Performs a deep comparison between two values to determine if they are
  12324. * equivalent.
  12325. *
  12326. * **Note:** This method supports comparing arrays, array buffers, booleans,
  12327. * date objects, error objects, maps, numbers, `Object` objects, regexes,
  12328. * sets, strings, symbols, and typed arrays. `Object` objects are compared
  12329. * by their own, not inherited, enumerable properties. Functions and DOM
  12330. * nodes are compared by strict equality, i.e. `===`.
  12331. *
  12332. * @static
  12333. * @memberOf _
  12334. * @since 0.1.0
  12335. * @category Lang
  12336. * @param {*} value The value to compare.
  12337. * @param {*} other The other value to compare.
  12338. * @returns {boolean} Returns `true` if the values are equivalent, else `false`.
  12339. * @example
  12340. *
  12341. * var object = { 'a': 1 };
  12342. * var other = { 'a': 1 };
  12343. *
  12344. * _.isEqual(object, other);
  12345. * // => true
  12346. *
  12347. * object === other;
  12348. * // => false
  12349. */
  12350. function isEqual(value, other) {
  12351. return baseIsEqual(value, other);
  12352. }
  12353. /**
  12354. * This method is like `_.isEqual` except that it accepts `customizer` which
  12355. * is invoked to compare values. If `customizer` returns `undefined`, comparisons
  12356. * are handled by the method instead. The `customizer` is invoked with up to
  12357. * six arguments: (objValue, othValue [, index|key, object, other, stack]).
  12358. *
  12359. * @static
  12360. * @memberOf _
  12361. * @since 4.0.0
  12362. * @category Lang
  12363. * @param {*} value The value to compare.
  12364. * @param {*} other The other value to compare.
  12365. * @param {Function} [customizer] The function to customize comparisons.
  12366. * @returns {boolean} Returns `true` if the values are equivalent, else `false`.
  12367. * @example
  12368. *
  12369. * function isGreeting(value) {
  12370. * return /^h(?:i|ello)$/.test(value);
  12371. * }
  12372. *
  12373. * function customizer(objValue, othValue) {
  12374. * if (isGreeting(objValue) && isGreeting(othValue)) {
  12375. * return true;
  12376. * }
  12377. * }
  12378. *
  12379. * var array = ['hello', 'goodbye'];
  12380. * var other = ['hi', 'goodbye'];
  12381. *
  12382. * _.isEqualWith(array, other, customizer);
  12383. * // => true
  12384. */
  12385. function isEqualWith(value, other, customizer) {
  12386. customizer = typeof customizer == 'function' ? customizer : undefined;
  12387. var result = customizer ? customizer(value, other) : undefined;
  12388. return result === undefined ? baseIsEqual(value, other, undefined, customizer) : !!result;
  12389. }
  12390. /**
  12391. * Checks if `value` is an `Error`, `EvalError`, `RangeError`, `ReferenceError`,
  12392. * `SyntaxError`, `TypeError`, or `URIError` object.
  12393. *
  12394. * @static
  12395. * @memberOf _
  12396. * @since 3.0.0
  12397. * @category Lang
  12398. * @param {*} value The value to check.
  12399. * @returns {boolean} Returns `true` if `value` is an error object, else `false`.
  12400. * @example
  12401. *
  12402. * _.isError(new Error);
  12403. * // => true
  12404. *
  12405. * _.isError(Error);
  12406. * // => false
  12407. */
  12408. function isError(value) {
  12409. if (!isObjectLike(value)) {
  12410. return false;
  12411. }
  12412. var tag = baseGetTag(value);
  12413. return tag == errorTag || tag == domExcTag ||
  12414. (typeof value.message == 'string' && typeof value.name == 'string' && !isPlainObject(value));
  12415. }
  12416. /**
  12417. * Checks if `value` is a finite primitive number.
  12418. *
  12419. * **Note:** This method is based on
  12420. * [`Number.isFinite`](https://mdn.io/Number/isFinite).
  12421. *
  12422. * @static
  12423. * @memberOf _
  12424. * @since 0.1.0
  12425. * @category Lang
  12426. * @param {*} value The value to check.
  12427. * @returns {boolean} Returns `true` if `value` is a finite number, else `false`.
  12428. * @example
  12429. *
  12430. * _.isFinite(3);
  12431. * // => true
  12432. *
  12433. * _.isFinite(Number.MIN_VALUE);
  12434. * // => true
  12435. *
  12436. * _.isFinite(Infinity);
  12437. * // => false
  12438. *
  12439. * _.isFinite('3');
  12440. * // => false
  12441. */
  12442. function isFinite(value) {
  12443. return typeof value == 'number' && nativeIsFinite(value);
  12444. }
  12445. /**
  12446. * Checks if `value` is classified as a `Function` object.
  12447. *
  12448. * @static
  12449. * @memberOf _
  12450. * @since 0.1.0
  12451. * @category Lang
  12452. * @param {*} value The value to check.
  12453. * @returns {boolean} Returns `true` if `value` is a function, else `false`.
  12454. * @example
  12455. *
  12456. * _.isFunction(_);
  12457. * // => true
  12458. *
  12459. * _.isFunction(/abc/);
  12460. * // => false
  12461. */
  12462. function isFunction(value) {
  12463. if (!isObject(value)) {
  12464. return false;
  12465. }
  12466. // The use of `Object#toString` avoids issues with the `typeof` operator
  12467. // in Safari 9 which returns 'object' for typed arrays and other constructors.
  12468. var tag = baseGetTag(value);
  12469. return tag == funcTag || tag == genTag || tag == asyncTag || tag == proxyTag;
  12470. }
  12471. /**
  12472. * Checks if `value` is an integer.
  12473. *
  12474. * **Note:** This method is based on
  12475. * [`Number.isInteger`](https://mdn.io/Number/isInteger).
  12476. *
  12477. * @static
  12478. * @memberOf _
  12479. * @since 4.0.0
  12480. * @category Lang
  12481. * @param {*} value The value to check.
  12482. * @returns {boolean} Returns `true` if `value` is an integer, else `false`.
  12483. * @example
  12484. *
  12485. * _.isInteger(3);
  12486. * // => true
  12487. *
  12488. * _.isInteger(Number.MIN_VALUE);
  12489. * // => false
  12490. *
  12491. * _.isInteger(Infinity);
  12492. * // => false
  12493. *
  12494. * _.isInteger('3');
  12495. * // => false
  12496. */
  12497. function isInteger(value) {
  12498. return typeof value == 'number' && value == toInteger(value);
  12499. }
  12500. /**
  12501. * Checks if `value` is a valid array-like length.
  12502. *
  12503. * **Note:** This method is loosely based on
  12504. * [`ToLength`](http://ecma-international.org/ecma-262/7.0/#sec-tolength).
  12505. *
  12506. * @static
  12507. * @memberOf _
  12508. * @since 4.0.0
  12509. * @category Lang
  12510. * @param {*} value The value to check.
  12511. * @returns {boolean} Returns `true` if `value` is a valid length, else `false`.
  12512. * @example
  12513. *
  12514. * _.isLength(3);
  12515. * // => true
  12516. *
  12517. * _.isLength(Number.MIN_VALUE);
  12518. * // => false
  12519. *
  12520. * _.isLength(Infinity);
  12521. * // => false
  12522. *
  12523. * _.isLength('3');
  12524. * // => false
  12525. */
  12526. function isLength(value) {
  12527. return typeof value == 'number' &&
  12528. value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER;
  12529. }
  12530. /**
  12531. * Checks if `value` is the
  12532. * [language type](http://www.ecma-international.org/ecma-262/7.0/#sec-ecmascript-language-types)
  12533. * of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)
  12534. *
  12535. * @static
  12536. * @memberOf _
  12537. * @since 0.1.0
  12538. * @category Lang
  12539. * @param {*} value The value to check.
  12540. * @returns {boolean} Returns `true` if `value` is an object, else `false`.
  12541. * @example
  12542. *
  12543. * _.isObject({});
  12544. * // => true
  12545. *
  12546. * _.isObject([1, 2, 3]);
  12547. * // => true
  12548. *
  12549. * _.isObject(_.noop);
  12550. * // => true
  12551. *
  12552. * _.isObject(null);
  12553. * // => false
  12554. */
  12555. function isObject(value) {
  12556. var type = typeof value;
  12557. return value != null && (type == 'object' || type == 'function');
  12558. }
  12559. /**
  12560. * Checks if `value` is object-like. A value is object-like if it's not `null`
  12561. * and has a `typeof` result of "object".
  12562. *
  12563. * @static
  12564. * @memberOf _
  12565. * @since 4.0.0
  12566. * @category Lang
  12567. * @param {*} value The value to check.
  12568. * @returns {boolean} Returns `true` if `value` is object-like, else `false`.
  12569. * @example
  12570. *
  12571. * _.isObjectLike({});
  12572. * // => true
  12573. *
  12574. * _.isObjectLike([1, 2, 3]);
  12575. * // => true
  12576. *
  12577. * _.isObjectLike(_.noop);
  12578. * // => false
  12579. *
  12580. * _.isObjectLike(null);
  12581. * // => false
  12582. */
  12583. function isObjectLike(value) {
  12584. return value != null && typeof value == 'object';
  12585. }
  12586. /**
  12587. * Checks if `value` is classified as a `Map` object.
  12588. *
  12589. * @static
  12590. * @memberOf _
  12591. * @since 4.3.0
  12592. * @category Lang
  12593. * @param {*} value The value to check.
  12594. * @returns {boolean} Returns `true` if `value` is a map, else `false`.
  12595. * @example
  12596. *
  12597. * _.isMap(new Map);
  12598. * // => true
  12599. *
  12600. * _.isMap(new WeakMap);
  12601. * // => false
  12602. */
  12603. var isMap = nodeIsMap ? baseUnary(nodeIsMap) : baseIsMap;
  12604. /**
  12605. * Performs a partial deep comparison between `object` and `source` to
  12606. * determine if `object` contains equivalent property values.
  12607. *
  12608. * **Note:** This method is equivalent to `_.matches` when `source` is
  12609. * partially applied.
  12610. *
  12611. * Partial comparisons will match empty array and empty object `source`
  12612. * values against any array or object value, respectively. See `_.isEqual`
  12613. * for a list of supported value comparisons.
  12614. *
  12615. * @static
  12616. * @memberOf _
  12617. * @since 3.0.0
  12618. * @category Lang
  12619. * @param {Object} object The object to inspect.
  12620. * @param {Object} source The object of property values to match.
  12621. * @returns {boolean} Returns `true` if `object` is a match, else `false`.
  12622. * @example
  12623. *
  12624. * var object = { 'a': 1, 'b': 2 };
  12625. *
  12626. * _.isMatch(object, { 'b': 2 });
  12627. * // => true
  12628. *
  12629. * _.isMatch(object, { 'b': 1 });
  12630. * // => false
  12631. */
  12632. function isMatch(object, source) {
  12633. return object === source || baseIsMatch(object, source, getMatchData(source));
  12634. }
  12635. /**
  12636. * This method is like `_.isMatch` except that it accepts `customizer` which
  12637. * is invoked to compare values. If `customizer` returns `undefined`, comparisons
  12638. * are handled by the method instead. The `customizer` is invoked with five
  12639. * arguments: (objValue, srcValue, index|key, object, source).
  12640. *
  12641. * @static
  12642. * @memberOf _
  12643. * @since 4.0.0
  12644. * @category Lang
  12645. * @param {Object} object The object to inspect.
  12646. * @param {Object} source The object of property values to match.
  12647. * @param {Function} [customizer] The function to customize comparisons.
  12648. * @returns {boolean} Returns `true` if `object` is a match, else `false`.
  12649. * @example
  12650. *
  12651. * function isGreeting(value) {
  12652. * return /^h(?:i|ello)$/.test(value);
  12653. * }
  12654. *
  12655. * function customizer(objValue, srcValue) {
  12656. * if (isGreeting(objValue) && isGreeting(srcValue)) {
  12657. * return true;
  12658. * }
  12659. * }
  12660. *
  12661. * var object = { 'greeting': 'hello' };
  12662. * var source = { 'greeting': 'hi' };
  12663. *
  12664. * _.isMatchWith(object, source, customizer);
  12665. * // => true
  12666. */
  12667. function isMatchWith(object, source, customizer) {
  12668. customizer = typeof customizer == 'function' ? customizer : undefined;
  12669. return baseIsMatch(object, source, getMatchData(source), customizer);
  12670. }
  12671. /**
  12672. * Checks if `value` is `NaN`.
  12673. *
  12674. * **Note:** This method is based on
  12675. * [`Number.isNaN`](https://mdn.io/Number/isNaN) and is not the same as
  12676. * global [`isNaN`](https://mdn.io/isNaN) which returns `true` for
  12677. * `undefined` and other non-number values.
  12678. *
  12679. * @static
  12680. * @memberOf _
  12681. * @since 0.1.0
  12682. * @category Lang
  12683. * @param {*} value The value to check.
  12684. * @returns {boolean} Returns `true` if `value` is `NaN`, else `false`.
  12685. * @example
  12686. *
  12687. * _.isNaN(NaN);
  12688. * // => true
  12689. *
  12690. * _.isNaN(new Number(NaN));
  12691. * // => true
  12692. *
  12693. * isNaN(undefined);
  12694. * // => true
  12695. *
  12696. * _.isNaN(undefined);
  12697. * // => false
  12698. */
  12699. function isNaN(value) {
  12700. // An `NaN` primitive is the only value that is not equal to itself.
  12701. // Perform the `toStringTag` check first to avoid errors with some
  12702. // ActiveX objects in IE.
  12703. return isNumber(value) && value != +value;
  12704. }
  12705. /**
  12706. * Checks if `value` is a pristine native function.
  12707. *
  12708. * **Note:** This method can't reliably detect native functions in the presence
  12709. * of the core-js package because core-js circumvents this kind of detection.
  12710. * Despite multiple requests, the core-js maintainer has made it clear: any
  12711. * attempt to fix the detection will be obstructed. As a result, we're left
  12712. * with little choice but to throw an error. Unfortunately, this also affects
  12713. * packages, like [babel-polyfill](https://www.npmjs.com/package/babel-polyfill),
  12714. * which rely on core-js.
  12715. *
  12716. * @static
  12717. * @memberOf _
  12718. * @since 3.0.0
  12719. * @category Lang
  12720. * @param {*} value The value to check.
  12721. * @returns {boolean} Returns `true` if `value` is a native function,
  12722. * else `false`.
  12723. * @example
  12724. *
  12725. * _.isNative(Array.prototype.push);
  12726. * // => true
  12727. *
  12728. * _.isNative(_);
  12729. * // => false
  12730. */
  12731. function isNative(value) {
  12732. if (isMaskable(value)) {
  12733. throw new Error(CORE_ERROR_TEXT);
  12734. }
  12735. return baseIsNative(value);
  12736. }
  12737. /**
  12738. * Checks if `value` is `null`.
  12739. *
  12740. * @static
  12741. * @memberOf _
  12742. * @since 0.1.0
  12743. * @category Lang
  12744. * @param {*} value The value to check.
  12745. * @returns {boolean} Returns `true` if `value` is `null`, else `false`.
  12746. * @example
  12747. *
  12748. * _.isNull(null);
  12749. * // => true
  12750. *
  12751. * _.isNull(void 0);
  12752. * // => false
  12753. */
  12754. function isNull(value) {
  12755. return value === null;
  12756. }
  12757. /**
  12758. * Checks if `value` is `null` or `undefined`.
  12759. *
  12760. * @static
  12761. * @memberOf _
  12762. * @since 4.0.0
  12763. * @category Lang
  12764. * @param {*} value The value to check.
  12765. * @returns {boolean} Returns `true` if `value` is nullish, else `false`.
  12766. * @example
  12767. *
  12768. * _.isNil(null);
  12769. * // => true
  12770. *
  12771. * _.isNil(void 0);
  12772. * // => true
  12773. *
  12774. * _.isNil(NaN);
  12775. * // => false
  12776. */
  12777. function isNil(value) {
  12778. return value == null;
  12779. }
  12780. /**
  12781. * Checks if `value` is classified as a `Number` primitive or object.
  12782. *
  12783. * **Note:** To exclude `Infinity`, `-Infinity`, and `NaN`, which are
  12784. * classified as numbers, use the `_.isFinite` method.
  12785. *
  12786. * @static
  12787. * @memberOf _
  12788. * @since 0.1.0
  12789. * @category Lang
  12790. * @param {*} value The value to check.
  12791. * @returns {boolean} Returns `true` if `value` is a number, else `false`.
  12792. * @example
  12793. *
  12794. * _.isNumber(3);
  12795. * // => true
  12796. *
  12797. * _.isNumber(Number.MIN_VALUE);
  12798. * // => true
  12799. *
  12800. * _.isNumber(Infinity);
  12801. * // => true
  12802. *
  12803. * _.isNumber('3');
  12804. * // => false
  12805. */
  12806. function isNumber(value) {
  12807. return typeof value == 'number' ||
  12808. (isObjectLike(value) && baseGetTag(value) == numberTag);
  12809. }
  12810. /**
  12811. * Checks if `value` is a plain object, that is, an object created by the
  12812. * `Object` constructor or one with a `[[Prototype]]` of `null`.
  12813. *
  12814. * @static
  12815. * @memberOf _
  12816. * @since 0.8.0
  12817. * @category Lang
  12818. * @param {*} value The value to check.
  12819. * @returns {boolean} Returns `true` if `value` is a plain object, else `false`.
  12820. * @example
  12821. *
  12822. * function Foo() {
  12823. * this.a = 1;
  12824. * }
  12825. *
  12826. * _.isPlainObject(new Foo);
  12827. * // => false
  12828. *
  12829. * _.isPlainObject([1, 2, 3]);
  12830. * // => false
  12831. *
  12832. * _.isPlainObject({ 'x': 0, 'y': 0 });
  12833. * // => true
  12834. *
  12835. * _.isPlainObject(Object.create(null));
  12836. * // => true
  12837. */
  12838. function isPlainObject(value) {
  12839. if (!isObjectLike(value) || baseGetTag(value) != objectTag) {
  12840. return false;
  12841. }
  12842. var proto = getPrototype(value);
  12843. if (proto === null) {
  12844. return true;
  12845. }
  12846. var Ctor = hasOwnProperty.call(proto, 'constructor') && proto.constructor;
  12847. return typeof Ctor == 'function' && Ctor instanceof Ctor &&
  12848. funcToString.call(Ctor) == objectCtorString;
  12849. }
  12850. /**
  12851. * Checks if `value` is classified as a `RegExp` object.
  12852. *
  12853. * @static
  12854. * @memberOf _
  12855. * @since 0.1.0
  12856. * @category Lang
  12857. * @param {*} value The value to check.
  12858. * @returns {boolean} Returns `true` if `value` is a regexp, else `false`.
  12859. * @example
  12860. *
  12861. * _.isRegExp(/abc/);
  12862. * // => true
  12863. *
  12864. * _.isRegExp('/abc/');
  12865. * // => false
  12866. */
  12867. var isRegExp = nodeIsRegExp ? baseUnary(nodeIsRegExp) : baseIsRegExp;
  12868. /**
  12869. * Checks if `value` is a safe integer. An integer is safe if it's an IEEE-754
  12870. * double precision number which isn't the result of a rounded unsafe integer.
  12871. *
  12872. * **Note:** This method is based on
  12873. * [`Number.isSafeInteger`](https://mdn.io/Number/isSafeInteger).
  12874. *
  12875. * @static
  12876. * @memberOf _
  12877. * @since 4.0.0
  12878. * @category Lang
  12879. * @param {*} value The value to check.
  12880. * @returns {boolean} Returns `true` if `value` is a safe integer, else `false`.
  12881. * @example
  12882. *
  12883. * _.isSafeInteger(3);
  12884. * // => true
  12885. *
  12886. * _.isSafeInteger(Number.MIN_VALUE);
  12887. * // => false
  12888. *
  12889. * _.isSafeInteger(Infinity);
  12890. * // => false
  12891. *
  12892. * _.isSafeInteger('3');
  12893. * // => false
  12894. */
  12895. function isSafeInteger(value) {
  12896. return isInteger(value) && value >= -MAX_SAFE_INTEGER && value <= MAX_SAFE_INTEGER;
  12897. }
  12898. /**
  12899. * Checks if `value` is classified as a `Set` object.
  12900. *
  12901. * @static
  12902. * @memberOf _
  12903. * @since 4.3.0
  12904. * @category Lang
  12905. * @param {*} value The value to check.
  12906. * @returns {boolean} Returns `true` if `value` is a set, else `false`.
  12907. * @example
  12908. *
  12909. * _.isSet(new Set);
  12910. * // => true
  12911. *
  12912. * _.isSet(new WeakSet);
  12913. * // => false
  12914. */
  12915. var isSet = nodeIsSet ? baseUnary(nodeIsSet) : baseIsSet;
  12916. /**
  12917. * Checks if `value` is classified as a `String` primitive or object.
  12918. *
  12919. * @static
  12920. * @since 0.1.0
  12921. * @memberOf _
  12922. * @category Lang
  12923. * @param {*} value The value to check.
  12924. * @returns {boolean} Returns `true` if `value` is a string, else `false`.
  12925. * @example
  12926. *
  12927. * _.isString('abc');
  12928. * // => true
  12929. *
  12930. * _.isString(1);
  12931. * // => false
  12932. */
  12933. function isString(value) {
  12934. return typeof value == 'string' ||
  12935. (!isArray(value) && isObjectLike(value) && baseGetTag(value) == stringTag);
  12936. }
  12937. /**
  12938. * Checks if `value` is classified as a `Symbol` primitive or object.
  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 a symbol, else `false`.
  12946. * @example
  12947. *
  12948. * _.isSymbol(Symbol.iterator);
  12949. * // => true
  12950. *
  12951. * _.isSymbol('abc');
  12952. * // => false
  12953. */
  12954. function isSymbol(value) {
  12955. return typeof value == 'symbol' ||
  12956. (isObjectLike(value) && baseGetTag(value) == symbolTag);
  12957. }
  12958. /**
  12959. * Checks if `value` is classified as a typed array.
  12960. *
  12961. * @static
  12962. * @memberOf _
  12963. * @since 3.0.0
  12964. * @category Lang
  12965. * @param {*} value The value to check.
  12966. * @returns {boolean} Returns `true` if `value` is a typed array, else `false`.
  12967. * @example
  12968. *
  12969. * _.isTypedArray(new Uint8Array);
  12970. * // => true
  12971. *
  12972. * _.isTypedArray([]);
  12973. * // => false
  12974. */
  12975. var isTypedArray = nodeIsTypedArray ? baseUnary(nodeIsTypedArray) : baseIsTypedArray;
  12976. /**
  12977. * Checks if `value` is `undefined`.
  12978. *
  12979. * @static
  12980. * @since 0.1.0
  12981. * @memberOf _
  12982. * @category Lang
  12983. * @param {*} value The value to check.
  12984. * @returns {boolean} Returns `true` if `value` is `undefined`, else `false`.
  12985. * @example
  12986. *
  12987. * _.isUndefined(void 0);
  12988. * // => true
  12989. *
  12990. * _.isUndefined(null);
  12991. * // => false
  12992. */
  12993. function isUndefined(value) {
  12994. return value === undefined;
  12995. }
  12996. /**
  12997. * Checks if `value` is classified as a `WeakMap` object.
  12998. *
  12999. * @static
  13000. * @memberOf _
  13001. * @since 4.3.0
  13002. * @category Lang
  13003. * @param {*} value The value to check.
  13004. * @returns {boolean} Returns `true` if `value` is a weak map, else `false`.
  13005. * @example
  13006. *
  13007. * _.isWeakMap(new WeakMap);
  13008. * // => true
  13009. *
  13010. * _.isWeakMap(new Map);
  13011. * // => false
  13012. */
  13013. function isWeakMap(value) {
  13014. return isObjectLike(value) && getTag(value) == weakMapTag;
  13015. }
  13016. /**
  13017. * Checks if `value` is classified as a `WeakSet` object.
  13018. *
  13019. * @static
  13020. * @memberOf _
  13021. * @since 4.3.0
  13022. * @category Lang
  13023. * @param {*} value The value to check.
  13024. * @returns {boolean} Returns `true` if `value` is a weak set, else `false`.
  13025. * @example
  13026. *
  13027. * _.isWeakSet(new WeakSet);
  13028. * // => true
  13029. *
  13030. * _.isWeakSet(new Set);
  13031. * // => false
  13032. */
  13033. function isWeakSet(value) {
  13034. return isObjectLike(value) && baseGetTag(value) == weakSetTag;
  13035. }
  13036. /**
  13037. * Checks if `value` is less than `other`.
  13038. *
  13039. * @static
  13040. * @memberOf _
  13041. * @since 3.9.0
  13042. * @category Lang
  13043. * @param {*} value The value to compare.
  13044. * @param {*} other The other value to compare.
  13045. * @returns {boolean} Returns `true` if `value` is less than `other`,
  13046. * else `false`.
  13047. * @see _.gt
  13048. * @example
  13049. *
  13050. * _.lt(1, 3);
  13051. * // => true
  13052. *
  13053. * _.lt(3, 3);
  13054. * // => false
  13055. *
  13056. * _.lt(3, 1);
  13057. * // => false
  13058. */
  13059. var lt = createRelationalOperation(baseLt);
  13060. /**
  13061. * Checks if `value` is less than or equal to `other`.
  13062. *
  13063. * @static
  13064. * @memberOf _
  13065. * @since 3.9.0
  13066. * @category Lang
  13067. * @param {*} value The value to compare.
  13068. * @param {*} other The other value to compare.
  13069. * @returns {boolean} Returns `true` if `value` is less than or equal to
  13070. * `other`, else `false`.
  13071. * @see _.gte
  13072. * @example
  13073. *
  13074. * _.lte(1, 3);
  13075. * // => true
  13076. *
  13077. * _.lte(3, 3);
  13078. * // => true
  13079. *
  13080. * _.lte(3, 1);
  13081. * // => false
  13082. */
  13083. var lte = createRelationalOperation(function(value, other) {
  13084. return value <= other;
  13085. });
  13086. /**
  13087. * Converts `value` to an array.
  13088. *
  13089. * @static
  13090. * @since 0.1.0
  13091. * @memberOf _
  13092. * @category Lang
  13093. * @param {*} value The value to convert.
  13094. * @returns {Array} Returns the converted array.
  13095. * @example
  13096. *
  13097. * _.toArray({ 'a': 1, 'b': 2 });
  13098. * // => [1, 2]
  13099. *
  13100. * _.toArray('abc');
  13101. * // => ['a', 'b', 'c']
  13102. *
  13103. * _.toArray(1);
  13104. * // => []
  13105. *
  13106. * _.toArray(null);
  13107. * // => []
  13108. */
  13109. function toArray(value) {
  13110. if (!value) {
  13111. return [];
  13112. }
  13113. if (isArrayLike(value)) {
  13114. return isString(value) ? stringToArray(value) : copyArray(value);
  13115. }
  13116. if (symIterator && value[symIterator]) {
  13117. return iteratorToArray(value[symIterator]());
  13118. }
  13119. var tag = getTag(value),
  13120. func = tag == mapTag ? mapToArray : (tag == setTag ? setToArray : values);
  13121. return func(value);
  13122. }
  13123. /**
  13124. * Converts `value` to a finite number.
  13125. *
  13126. * @static
  13127. * @memberOf _
  13128. * @since 4.12.0
  13129. * @category Lang
  13130. * @param {*} value The value to convert.
  13131. * @returns {number} Returns the converted number.
  13132. * @example
  13133. *
  13134. * _.toFinite(3.2);
  13135. * // => 3.2
  13136. *
  13137. * _.toFinite(Number.MIN_VALUE);
  13138. * // => 5e-324
  13139. *
  13140. * _.toFinite(Infinity);
  13141. * // => 1.7976931348623157e+308
  13142. *
  13143. * _.toFinite('3.2');
  13144. * // => 3.2
  13145. */
  13146. function toFinite(value) {
  13147. if (!value) {
  13148. return value === 0 ? value : 0;
  13149. }
  13150. value = toNumber(value);
  13151. if (value === INFINITY || value === -INFINITY) {
  13152. var sign = (value < 0 ? -1 : 1);
  13153. return sign * MAX_INTEGER;
  13154. }
  13155. return value === value ? value : 0;
  13156. }
  13157. /**
  13158. * Converts `value` to an integer.
  13159. *
  13160. * **Note:** This method is loosely based on
  13161. * [`ToInteger`](http://www.ecma-international.org/ecma-262/7.0/#sec-tointeger).
  13162. *
  13163. * @static
  13164. * @memberOf _
  13165. * @since 4.0.0
  13166. * @category Lang
  13167. * @param {*} value The value to convert.
  13168. * @returns {number} Returns the converted integer.
  13169. * @example
  13170. *
  13171. * _.toInteger(3.2);
  13172. * // => 3
  13173. *
  13174. * _.toInteger(Number.MIN_VALUE);
  13175. * // => 0
  13176. *
  13177. * _.toInteger(Infinity);
  13178. * // => 1.7976931348623157e+308
  13179. *
  13180. * _.toInteger('3.2');
  13181. * // => 3
  13182. */
  13183. function toInteger(value) {
  13184. var result = toFinite(value),
  13185. remainder = result % 1;
  13186. return result === result ? (remainder ? result - remainder : result) : 0;
  13187. }
  13188. /**
  13189. * Converts `value` to an integer suitable for use as the length of an
  13190. * array-like object.
  13191. *
  13192. * **Note:** This method is based on
  13193. * [`ToLength`](http://ecma-international.org/ecma-262/7.0/#sec-tolength).
  13194. *
  13195. * @static
  13196. * @memberOf _
  13197. * @since 4.0.0
  13198. * @category Lang
  13199. * @param {*} value The value to convert.
  13200. * @returns {number} Returns the converted integer.
  13201. * @example
  13202. *
  13203. * _.toLength(3.2);
  13204. * // => 3
  13205. *
  13206. * _.toLength(Number.MIN_VALUE);
  13207. * // => 0
  13208. *
  13209. * _.toLength(Infinity);
  13210. * // => 4294967295
  13211. *
  13212. * _.toLength('3.2');
  13213. * // => 3
  13214. */
  13215. function toLength(value) {
  13216. return value ? baseClamp(toInteger(value), 0, MAX_ARRAY_LENGTH) : 0;
  13217. }
  13218. /**
  13219. * Converts `value` to a number.
  13220. *
  13221. * @static
  13222. * @memberOf _
  13223. * @since 4.0.0
  13224. * @category Lang
  13225. * @param {*} value The value to process.
  13226. * @returns {number} Returns the number.
  13227. * @example
  13228. *
  13229. * _.toNumber(3.2);
  13230. * // => 3.2
  13231. *
  13232. * _.toNumber(Number.MIN_VALUE);
  13233. * // => 5e-324
  13234. *
  13235. * _.toNumber(Infinity);
  13236. * // => Infinity
  13237. *
  13238. * _.toNumber('3.2');
  13239. * // => 3.2
  13240. */
  13241. function toNumber(value) {
  13242. if (typeof value == 'number') {
  13243. return value;
  13244. }
  13245. if (isSymbol(value)) {
  13246. return NAN;
  13247. }
  13248. if (isObject(value)) {
  13249. var other = typeof value.valueOf == 'function' ? value.valueOf() : value;
  13250. value = isObject(other) ? (other + '') : other;
  13251. }
  13252. if (typeof value != 'string') {
  13253. return value === 0 ? value : +value;
  13254. }
  13255. value = value.replace(reTrim, '');
  13256. var isBinary = reIsBinary.test(value);
  13257. return (isBinary || reIsOctal.test(value))
  13258. ? freeParseInt(value.slice(2), isBinary ? 2 : 8)
  13259. : (reIsBadHex.test(value) ? NAN : +value);
  13260. }
  13261. /**
  13262. * Converts `value` to a plain object flattening inherited enumerable string
  13263. * keyed properties of `value` to own properties of the plain object.
  13264. *
  13265. * @static
  13266. * @memberOf _
  13267. * @since 3.0.0
  13268. * @category Lang
  13269. * @param {*} value The value to convert.
  13270. * @returns {Object} Returns the converted plain object.
  13271. * @example
  13272. *
  13273. * function Foo() {
  13274. * this.b = 2;
  13275. * }
  13276. *
  13277. * Foo.prototype.c = 3;
  13278. *
  13279. * _.assign({ 'a': 1 }, new Foo);
  13280. * // => { 'a': 1, 'b': 2 }
  13281. *
  13282. * _.assign({ 'a': 1 }, _.toPlainObject(new Foo));
  13283. * // => { 'a': 1, 'b': 2, 'c': 3 }
  13284. */
  13285. function toPlainObject(value) {
  13286. return copyObject(value, keysIn(value));
  13287. }
  13288. /**
  13289. * Converts `value` to a safe integer. A safe integer can be compared and
  13290. * represented correctly.
  13291. *
  13292. * @static
  13293. * @memberOf _
  13294. * @since 4.0.0
  13295. * @category Lang
  13296. * @param {*} value The value to convert.
  13297. * @returns {number} Returns the converted integer.
  13298. * @example
  13299. *
  13300. * _.toSafeInteger(3.2);
  13301. * // => 3
  13302. *
  13303. * _.toSafeInteger(Number.MIN_VALUE);
  13304. * // => 0
  13305. *
  13306. * _.toSafeInteger(Infinity);
  13307. * // => 9007199254740991
  13308. *
  13309. * _.toSafeInteger('3.2');
  13310. * // => 3
  13311. */
  13312. function toSafeInteger(value) {
  13313. return value
  13314. ? baseClamp(toInteger(value), -MAX_SAFE_INTEGER, MAX_SAFE_INTEGER)
  13315. : (value === 0 ? value : 0);
  13316. }
  13317. /**
  13318. * Converts `value` to a string. An empty string is returned for `null`
  13319. * and `undefined` values. The sign of `-0` is preserved.
  13320. *
  13321. * @static
  13322. * @memberOf _
  13323. * @since 4.0.0
  13324. * @category Lang
  13325. * @param {*} value The value to convert.
  13326. * @returns {string} Returns the converted string.
  13327. * @example
  13328. *
  13329. * _.toString(null);
  13330. * // => ''
  13331. *
  13332. * _.toString(-0);
  13333. * // => '-0'
  13334. *
  13335. * _.toString([1, 2, 3]);
  13336. * // => '1,2,3'
  13337. */
  13338. function toString(value) {
  13339. return value == null ? '' : baseToString(value);
  13340. }
  13341. /*------------------------------------------------------------------------*/
  13342. /**
  13343. * Assigns own enumerable string keyed properties of source objects to the
  13344. * destination object. Source objects are applied from left to right.
  13345. * Subsequent sources overwrite property assignments of previous sources.
  13346. *
  13347. * **Note:** This method mutates `object` and is loosely based on
  13348. * [`Object.assign`](https://mdn.io/Object/assign).
  13349. *
  13350. * @static
  13351. * @memberOf _
  13352. * @since 0.10.0
  13353. * @category Object
  13354. * @param {Object} object The destination object.
  13355. * @param {...Object} [sources] The source objects.
  13356. * @returns {Object} Returns `object`.
  13357. * @see _.assignIn
  13358. * @example
  13359. *
  13360. * function Foo() {
  13361. * this.a = 1;
  13362. * }
  13363. *
  13364. * function Bar() {
  13365. * this.c = 3;
  13366. * }
  13367. *
  13368. * Foo.prototype.b = 2;
  13369. * Bar.prototype.d = 4;
  13370. *
  13371. * _.assign({ 'a': 0 }, new Foo, new Bar);
  13372. * // => { 'a': 1, 'c': 3 }
  13373. */
  13374. var assign = createAssigner(function(object, source) {
  13375. if (isPrototype(source) || isArrayLike(source)) {
  13376. copyObject(source, keys(source), object);
  13377. return;
  13378. }
  13379. for (var key in source) {
  13380. if (hasOwnProperty.call(source, key)) {
  13381. assignValue(object, key, source[key]);
  13382. }
  13383. }
  13384. });
  13385. /**
  13386. * This method is like `_.assign` except that it iterates over own and
  13387. * inherited source properties.
  13388. *
  13389. * **Note:** This method mutates `object`.
  13390. *
  13391. * @static
  13392. * @memberOf _
  13393. * @since 4.0.0
  13394. * @alias extend
  13395. * @category Object
  13396. * @param {Object} object The destination object.
  13397. * @param {...Object} [sources] The source objects.
  13398. * @returns {Object} Returns `object`.
  13399. * @see _.assign
  13400. * @example
  13401. *
  13402. * function Foo() {
  13403. * this.a = 1;
  13404. * }
  13405. *
  13406. * function Bar() {
  13407. * this.c = 3;
  13408. * }
  13409. *
  13410. * Foo.prototype.b = 2;
  13411. * Bar.prototype.d = 4;
  13412. *
  13413. * _.assignIn({ 'a': 0 }, new Foo, new Bar);
  13414. * // => { 'a': 1, 'b': 2, 'c': 3, 'd': 4 }
  13415. */
  13416. var assignIn = createAssigner(function(object, source) {
  13417. copyObject(source, keysIn(source), object);
  13418. });
  13419. /**
  13420. * This method is like `_.assignIn` except that it accepts `customizer`
  13421. * which is invoked to produce the assigned values. If `customizer` returns
  13422. * `undefined`, assignment is handled by the method instead. The `customizer`
  13423. * is invoked with five arguments: (objValue, srcValue, key, object, source).
  13424. *
  13425. * **Note:** This method mutates `object`.
  13426. *
  13427. * @static
  13428. * @memberOf _
  13429. * @since 4.0.0
  13430. * @alias extendWith
  13431. * @category Object
  13432. * @param {Object} object The destination object.
  13433. * @param {...Object} sources The source objects.
  13434. * @param {Function} [customizer] The function to customize assigned values.
  13435. * @returns {Object} Returns `object`.
  13436. * @see _.assignWith
  13437. * @example
  13438. *
  13439. * function customizer(objValue, srcValue) {
  13440. * return _.isUndefined(objValue) ? srcValue : objValue;
  13441. * }
  13442. *
  13443. * var defaults = _.partialRight(_.assignInWith, customizer);
  13444. *
  13445. * defaults({ 'a': 1 }, { 'b': 2 }, { 'a': 3 });
  13446. * // => { 'a': 1, 'b': 2 }
  13447. */
  13448. var assignInWith = createAssigner(function(object, source, srcIndex, customizer) {
  13449. copyObject(source, keysIn(source), object, customizer);
  13450. });
  13451. /**
  13452. * This method is like `_.assign` except that it accepts `customizer`
  13453. * which is invoked to produce the assigned values. If `customizer` returns
  13454. * `undefined`, assignment is handled by the method instead. The `customizer`
  13455. * is invoked with five arguments: (objValue, srcValue, key, object, source).
  13456. *
  13457. * **Note:** This method mutates `object`.
  13458. *
  13459. * @static
  13460. * @memberOf _
  13461. * @since 4.0.0
  13462. * @category Object
  13463. * @param {Object} object The destination object.
  13464. * @param {...Object} sources The source objects.
  13465. * @param {Function} [customizer] The function to customize assigned values.
  13466. * @returns {Object} Returns `object`.
  13467. * @see _.assignInWith
  13468. * @example
  13469. *
  13470. * function customizer(objValue, srcValue) {
  13471. * return _.isUndefined(objValue) ? srcValue : objValue;
  13472. * }
  13473. *
  13474. * var defaults = _.partialRight(_.assignWith, customizer);
  13475. *
  13476. * defaults({ 'a': 1 }, { 'b': 2 }, { 'a': 3 });
  13477. * // => { 'a': 1, 'b': 2 }
  13478. */
  13479. var assignWith = createAssigner(function(object, source, srcIndex, customizer) {
  13480. copyObject(source, keys(source), object, customizer);
  13481. });
  13482. /**
  13483. * Creates an array of values corresponding to `paths` of `object`.
  13484. *
  13485. * @static
  13486. * @memberOf _
  13487. * @since 1.0.0
  13488. * @category Object
  13489. * @param {Object} object The object to iterate over.
  13490. * @param {...(string|string[])} [paths] The property paths to pick.
  13491. * @returns {Array} Returns the picked values.
  13492. * @example
  13493. *
  13494. * var object = { 'a': [{ 'b': { 'c': 3 } }, 4] };
  13495. *
  13496. * _.at(object, ['a[0].b.c', 'a[1]']);
  13497. * // => [3, 4]
  13498. */
  13499. var at = flatRest(baseAt);
  13500. /**
  13501. * Creates an object that inherits from the `prototype` object. If a
  13502. * `properties` object is given, its own enumerable string keyed properties
  13503. * are assigned to the created object.
  13504. *
  13505. * @static
  13506. * @memberOf _
  13507. * @since 2.3.0
  13508. * @category Object
  13509. * @param {Object} prototype The object to inherit from.
  13510. * @param {Object} [properties] The properties to assign to the object.
  13511. * @returns {Object} Returns the new object.
  13512. * @example
  13513. *
  13514. * function Shape() {
  13515. * this.x = 0;
  13516. * this.y = 0;
  13517. * }
  13518. *
  13519. * function Circle() {
  13520. * Shape.call(this);
  13521. * }
  13522. *
  13523. * Circle.prototype = _.create(Shape.prototype, {
  13524. * 'constructor': Circle
  13525. * });
  13526. *
  13527. * var circle = new Circle;
  13528. * circle instanceof Circle;
  13529. * // => true
  13530. *
  13531. * circle instanceof Shape;
  13532. * // => true
  13533. */
  13534. function create(prototype, properties) {
  13535. var result = baseCreate(prototype);
  13536. return properties == null ? result : baseAssign(result, properties);
  13537. }
  13538. /**
  13539. * Assigns own and inherited enumerable string keyed properties of source
  13540. * objects to the destination object for all destination properties that
  13541. * resolve to `undefined`. Source objects are applied from left to right.
  13542. * Once a property is set, additional values of the same property are ignored.
  13543. *
  13544. * **Note:** This method mutates `object`.
  13545. *
  13546. * @static
  13547. * @since 0.1.0
  13548. * @memberOf _
  13549. * @category Object
  13550. * @param {Object} object The destination object.
  13551. * @param {...Object} [sources] The source objects.
  13552. * @returns {Object} Returns `object`.
  13553. * @see _.defaultsDeep
  13554. * @example
  13555. *
  13556. * _.defaults({ 'a': 1 }, { 'b': 2 }, { 'a': 3 });
  13557. * // => { 'a': 1, 'b': 2 }
  13558. */
  13559. var defaults = baseRest(function(object, sources) {
  13560. object = Object(object);
  13561. var index = -1;
  13562. var length = sources.length;
  13563. var guard = length > 2 ? sources[2] : undefined;
  13564. if (guard && isIterateeCall(sources[0], sources[1], guard)) {
  13565. length = 1;
  13566. }
  13567. while (++index < length) {
  13568. var source = sources[index];
  13569. var props = keysIn(source);
  13570. var propsIndex = -1;
  13571. var propsLength = props.length;
  13572. while (++propsIndex < propsLength) {
  13573. var key = props[propsIndex];
  13574. var value = object[key];
  13575. if (value === undefined ||
  13576. (eq(value, objectProto[key]) && !hasOwnProperty.call(object, key))) {
  13577. object[key] = source[key];
  13578. }
  13579. }
  13580. }
  13581. return object;
  13582. });
  13583. /**
  13584. * This method is like `_.defaults` except that it recursively assigns
  13585. * default properties.
  13586. *
  13587. * **Note:** This method mutates `object`.
  13588. *
  13589. * @static
  13590. * @memberOf _
  13591. * @since 3.10.0
  13592. * @category Object
  13593. * @param {Object} object The destination object.
  13594. * @param {...Object} [sources] The source objects.
  13595. * @returns {Object} Returns `object`.
  13596. * @see _.defaults
  13597. * @example
  13598. *
  13599. * _.defaultsDeep({ 'a': { 'b': 2 } }, { 'a': { 'b': 1, 'c': 3 } });
  13600. * // => { 'a': { 'b': 2, 'c': 3 } }
  13601. */
  13602. var defaultsDeep = baseRest(function(args) {
  13603. args.push(undefined, customDefaultsMerge);
  13604. return apply(mergeWith, undefined, args);
  13605. });
  13606. /**
  13607. * This method is like `_.find` except that it returns the key of the first
  13608. * element `predicate` returns truthy for instead of the element itself.
  13609. *
  13610. * @static
  13611. * @memberOf _
  13612. * @since 1.1.0
  13613. * @category Object
  13614. * @param {Object} object The object to inspect.
  13615. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  13616. * @returns {string|undefined} Returns the key of the matched element,
  13617. * else `undefined`.
  13618. * @example
  13619. *
  13620. * var users = {
  13621. * 'barney': { 'age': 36, 'active': true },
  13622. * 'fred': { 'age': 40, 'active': false },
  13623. * 'pebbles': { 'age': 1, 'active': true }
  13624. * };
  13625. *
  13626. * _.findKey(users, function(o) { return o.age < 40; });
  13627. * // => 'barney' (iteration order is not guaranteed)
  13628. *
  13629. * // The `_.matches` iteratee shorthand.
  13630. * _.findKey(users, { 'age': 1, 'active': true });
  13631. * // => 'pebbles'
  13632. *
  13633. * // The `_.matchesProperty` iteratee shorthand.
  13634. * _.findKey(users, ['active', false]);
  13635. * // => 'fred'
  13636. *
  13637. * // The `_.property` iteratee shorthand.
  13638. * _.findKey(users, 'active');
  13639. * // => 'barney'
  13640. */
  13641. function findKey(object, predicate) {
  13642. return baseFindKey(object, getIteratee(predicate, 3), baseForOwn);
  13643. }
  13644. /**
  13645. * This method is like `_.findKey` except that it iterates over elements of
  13646. * a collection in the opposite order.
  13647. *
  13648. * @static
  13649. * @memberOf _
  13650. * @since 2.0.0
  13651. * @category Object
  13652. * @param {Object} object The object to inspect.
  13653. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  13654. * @returns {string|undefined} Returns the key of the matched element,
  13655. * else `undefined`.
  13656. * @example
  13657. *
  13658. * var users = {
  13659. * 'barney': { 'age': 36, 'active': true },
  13660. * 'fred': { 'age': 40, 'active': false },
  13661. * 'pebbles': { 'age': 1, 'active': true }
  13662. * };
  13663. *
  13664. * _.findLastKey(users, function(o) { return o.age < 40; });
  13665. * // => returns 'pebbles' assuming `_.findKey` returns 'barney'
  13666. *
  13667. * // The `_.matches` iteratee shorthand.
  13668. * _.findLastKey(users, { 'age': 36, 'active': true });
  13669. * // => 'barney'
  13670. *
  13671. * // The `_.matchesProperty` iteratee shorthand.
  13672. * _.findLastKey(users, ['active', false]);
  13673. * // => 'fred'
  13674. *
  13675. * // The `_.property` iteratee shorthand.
  13676. * _.findLastKey(users, 'active');
  13677. * // => 'pebbles'
  13678. */
  13679. function findLastKey(object, predicate) {
  13680. return baseFindKey(object, getIteratee(predicate, 3), baseForOwnRight);
  13681. }
  13682. /**
  13683. * Iterates over own and inherited enumerable string keyed properties of an
  13684. * object and invokes `iteratee` for each property. The iteratee is invoked
  13685. * with three arguments: (value, key, object). Iteratee functions may exit
  13686. * iteration early by explicitly returning `false`.
  13687. *
  13688. * @static
  13689. * @memberOf _
  13690. * @since 0.3.0
  13691. * @category Object
  13692. * @param {Object} object The object to iterate over.
  13693. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  13694. * @returns {Object} Returns `object`.
  13695. * @see _.forInRight
  13696. * @example
  13697. *
  13698. * function Foo() {
  13699. * this.a = 1;
  13700. * this.b = 2;
  13701. * }
  13702. *
  13703. * Foo.prototype.c = 3;
  13704. *
  13705. * _.forIn(new Foo, function(value, key) {
  13706. * console.log(key);
  13707. * });
  13708. * // => Logs 'a', 'b', then 'c' (iteration order is not guaranteed).
  13709. */
  13710. function forIn(object, iteratee) {
  13711. return object == null
  13712. ? object
  13713. : baseFor(object, getIteratee(iteratee, 3), keysIn);
  13714. }
  13715. /**
  13716. * This method is like `_.forIn` except that it iterates over properties of
  13717. * `object` in the opposite order.
  13718. *
  13719. * @static
  13720. * @memberOf _
  13721. * @since 2.0.0
  13722. * @category Object
  13723. * @param {Object} object The object to iterate over.
  13724. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  13725. * @returns {Object} Returns `object`.
  13726. * @see _.forIn
  13727. * @example
  13728. *
  13729. * function Foo() {
  13730. * this.a = 1;
  13731. * this.b = 2;
  13732. * }
  13733. *
  13734. * Foo.prototype.c = 3;
  13735. *
  13736. * _.forInRight(new Foo, function(value, key) {
  13737. * console.log(key);
  13738. * });
  13739. * // => Logs 'c', 'b', then 'a' assuming `_.forIn` logs 'a', 'b', then 'c'.
  13740. */
  13741. function forInRight(object, iteratee) {
  13742. return object == null
  13743. ? object
  13744. : baseForRight(object, getIteratee(iteratee, 3), keysIn);
  13745. }
  13746. /**
  13747. * Iterates over own enumerable string keyed properties of an object and
  13748. * invokes `iteratee` for each property. The iteratee is invoked with three
  13749. * arguments: (value, key, object). Iteratee functions may exit iteration
  13750. * early by explicitly returning `false`.
  13751. *
  13752. * @static
  13753. * @memberOf _
  13754. * @since 0.3.0
  13755. * @category Object
  13756. * @param {Object} object The object to iterate over.
  13757. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  13758. * @returns {Object} Returns `object`.
  13759. * @see _.forOwnRight
  13760. * @example
  13761. *
  13762. * function Foo() {
  13763. * this.a = 1;
  13764. * this.b = 2;
  13765. * }
  13766. *
  13767. * Foo.prototype.c = 3;
  13768. *
  13769. * _.forOwn(new Foo, function(value, key) {
  13770. * console.log(key);
  13771. * });
  13772. * // => Logs 'a' then 'b' (iteration order is not guaranteed).
  13773. */
  13774. function forOwn(object, iteratee) {
  13775. return object && baseForOwn(object, getIteratee(iteratee, 3));
  13776. }
  13777. /**
  13778. * This method is like `_.forOwn` except that it iterates over properties of
  13779. * `object` in the opposite order.
  13780. *
  13781. * @static
  13782. * @memberOf _
  13783. * @since 2.0.0
  13784. * @category Object
  13785. * @param {Object} object The object to iterate over.
  13786. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  13787. * @returns {Object} Returns `object`.
  13788. * @see _.forOwn
  13789. * @example
  13790. *
  13791. * function Foo() {
  13792. * this.a = 1;
  13793. * this.b = 2;
  13794. * }
  13795. *
  13796. * Foo.prototype.c = 3;
  13797. *
  13798. * _.forOwnRight(new Foo, function(value, key) {
  13799. * console.log(key);
  13800. * });
  13801. * // => Logs 'b' then 'a' assuming `_.forOwn` logs 'a' then 'b'.
  13802. */
  13803. function forOwnRight(object, iteratee) {
  13804. return object && baseForOwnRight(object, getIteratee(iteratee, 3));
  13805. }
  13806. /**
  13807. * Creates an array of function property names from own enumerable properties
  13808. * of `object`.
  13809. *
  13810. * @static
  13811. * @since 0.1.0
  13812. * @memberOf _
  13813. * @category Object
  13814. * @param {Object} object The object to inspect.
  13815. * @returns {Array} Returns the function names.
  13816. * @see _.functionsIn
  13817. * @example
  13818. *
  13819. * function Foo() {
  13820. * this.a = _.constant('a');
  13821. * this.b = _.constant('b');
  13822. * }
  13823. *
  13824. * Foo.prototype.c = _.constant('c');
  13825. *
  13826. * _.functions(new Foo);
  13827. * // => ['a', 'b']
  13828. */
  13829. function functions(object) {
  13830. return object == null ? [] : baseFunctions(object, keys(object));
  13831. }
  13832. /**
  13833. * Creates an array of function property names from own and inherited
  13834. * enumerable properties of `object`.
  13835. *
  13836. * @static
  13837. * @memberOf _
  13838. * @since 4.0.0
  13839. * @category Object
  13840. * @param {Object} object The object to inspect.
  13841. * @returns {Array} Returns the function names.
  13842. * @see _.functions
  13843. * @example
  13844. *
  13845. * function Foo() {
  13846. * this.a = _.constant('a');
  13847. * this.b = _.constant('b');
  13848. * }
  13849. *
  13850. * Foo.prototype.c = _.constant('c');
  13851. *
  13852. * _.functionsIn(new Foo);
  13853. * // => ['a', 'b', 'c']
  13854. */
  13855. function functionsIn(object) {
  13856. return object == null ? [] : baseFunctions(object, keysIn(object));
  13857. }
  13858. /**
  13859. * Gets the value at `path` of `object`. If the resolved value is
  13860. * `undefined`, the `defaultValue` is returned in its place.
  13861. *
  13862. * @static
  13863. * @memberOf _
  13864. * @since 3.7.0
  13865. * @category Object
  13866. * @param {Object} object The object to query.
  13867. * @param {Array|string} path The path of the property to get.
  13868. * @param {*} [defaultValue] The value returned for `undefined` resolved values.
  13869. * @returns {*} Returns the resolved value.
  13870. * @example
  13871. *
  13872. * var object = { 'a': [{ 'b': { 'c': 3 } }] };
  13873. *
  13874. * _.get(object, 'a[0].b.c');
  13875. * // => 3
  13876. *
  13877. * _.get(object, ['a', '0', 'b', 'c']);
  13878. * // => 3
  13879. *
  13880. * _.get(object, 'a.b.c', 'default');
  13881. * // => 'default'
  13882. */
  13883. function get(object, path, defaultValue) {
  13884. var result = object == null ? undefined : baseGet(object, path);
  13885. return result === undefined ? defaultValue : result;
  13886. }
  13887. /**
  13888. * Checks if `path` is a direct property of `object`.
  13889. *
  13890. * @static
  13891. * @since 0.1.0
  13892. * @memberOf _
  13893. * @category Object
  13894. * @param {Object} object The object to query.
  13895. * @param {Array|string} path The path to check.
  13896. * @returns {boolean} Returns `true` if `path` exists, else `false`.
  13897. * @example
  13898. *
  13899. * var object = { 'a': { 'b': 2 } };
  13900. * var other = _.create({ 'a': _.create({ 'b': 2 }) });
  13901. *
  13902. * _.has(object, 'a');
  13903. * // => true
  13904. *
  13905. * _.has(object, 'a.b');
  13906. * // => true
  13907. *
  13908. * _.has(object, ['a', 'b']);
  13909. * // => true
  13910. *
  13911. * _.has(other, 'a');
  13912. * // => false
  13913. */
  13914. function has(object, path) {
  13915. return object != null && hasPath(object, path, baseHas);
  13916. }
  13917. /**
  13918. * Checks if `path` is a direct or inherited property of `object`.
  13919. *
  13920. * @static
  13921. * @memberOf _
  13922. * @since 4.0.0
  13923. * @category Object
  13924. * @param {Object} object The object to query.
  13925. * @param {Array|string} path The path to check.
  13926. * @returns {boolean} Returns `true` if `path` exists, else `false`.
  13927. * @example
  13928. *
  13929. * var object = _.create({ 'a': _.create({ 'b': 2 }) });
  13930. *
  13931. * _.hasIn(object, 'a');
  13932. * // => true
  13933. *
  13934. * _.hasIn(object, 'a.b');
  13935. * // => true
  13936. *
  13937. * _.hasIn(object, ['a', 'b']);
  13938. * // => true
  13939. *
  13940. * _.hasIn(object, 'b');
  13941. * // => false
  13942. */
  13943. function hasIn(object, path) {
  13944. return object != null && hasPath(object, path, baseHasIn);
  13945. }
  13946. /**
  13947. * Creates an object composed of the inverted keys and values of `object`.
  13948. * If `object` contains duplicate values, subsequent values overwrite
  13949. * property assignments of previous values.
  13950. *
  13951. * @static
  13952. * @memberOf _
  13953. * @since 0.7.0
  13954. * @category Object
  13955. * @param {Object} object The object to invert.
  13956. * @returns {Object} Returns the new inverted object.
  13957. * @example
  13958. *
  13959. * var object = { 'a': 1, 'b': 2, 'c': 1 };
  13960. *
  13961. * _.invert(object);
  13962. * // => { '1': 'c', '2': 'b' }
  13963. */
  13964. var invert = createInverter(function(result, value, key) {
  13965. if (value != null &&
  13966. typeof value.toString != 'function') {
  13967. value = nativeObjectToString.call(value);
  13968. }
  13969. result[value] = key;
  13970. }, constant(identity));
  13971. /**
  13972. * This method is like `_.invert` except that the inverted object is generated
  13973. * from the results of running each element of `object` thru `iteratee`. The
  13974. * corresponding inverted value of each inverted key is an array of keys
  13975. * responsible for generating the inverted value. The iteratee is invoked
  13976. * with one argument: (value).
  13977. *
  13978. * @static
  13979. * @memberOf _
  13980. * @since 4.1.0
  13981. * @category Object
  13982. * @param {Object} object The object to invert.
  13983. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  13984. * @returns {Object} Returns the new inverted object.
  13985. * @example
  13986. *
  13987. * var object = { 'a': 1, 'b': 2, 'c': 1 };
  13988. *
  13989. * _.invertBy(object);
  13990. * // => { '1': ['a', 'c'], '2': ['b'] }
  13991. *
  13992. * _.invertBy(object, function(value) {
  13993. * return 'group' + value;
  13994. * });
  13995. * // => { 'group1': ['a', 'c'], 'group2': ['b'] }
  13996. */
  13997. var invertBy = createInverter(function(result, value, key) {
  13998. if (value != null &&
  13999. typeof value.toString != 'function') {
  14000. value = nativeObjectToString.call(value);
  14001. }
  14002. if (hasOwnProperty.call(result, value)) {
  14003. result[value].push(key);
  14004. } else {
  14005. result[value] = [key];
  14006. }
  14007. }, getIteratee);
  14008. /**
  14009. * Invokes the method at `path` of `object`.
  14010. *
  14011. * @static
  14012. * @memberOf _
  14013. * @since 4.0.0
  14014. * @category Object
  14015. * @param {Object} object The object to query.
  14016. * @param {Array|string} path The path of the method to invoke.
  14017. * @param {...*} [args] The arguments to invoke the method with.
  14018. * @returns {*} Returns the result of the invoked method.
  14019. * @example
  14020. *
  14021. * var object = { 'a': [{ 'b': { 'c': [1, 2, 3, 4] } }] };
  14022. *
  14023. * _.invoke(object, 'a[0].b.c.slice', 1, 3);
  14024. * // => [2, 3]
  14025. */
  14026. var invoke = baseRest(baseInvoke);
  14027. /**
  14028. * Creates an array of the own enumerable property names of `object`.
  14029. *
  14030. * **Note:** Non-object values are coerced to objects. See the
  14031. * [ES spec](http://ecma-international.org/ecma-262/7.0/#sec-object.keys)
  14032. * for more details.
  14033. *
  14034. * @static
  14035. * @since 0.1.0
  14036. * @memberOf _
  14037. * @category Object
  14038. * @param {Object} object The object to query.
  14039. * @returns {Array} Returns the array of property names.
  14040. * @example
  14041. *
  14042. * function Foo() {
  14043. * this.a = 1;
  14044. * this.b = 2;
  14045. * }
  14046. *
  14047. * Foo.prototype.c = 3;
  14048. *
  14049. * _.keys(new Foo);
  14050. * // => ['a', 'b'] (iteration order is not guaranteed)
  14051. *
  14052. * _.keys('hi');
  14053. * // => ['0', '1']
  14054. */
  14055. function keys(object) {
  14056. return isArrayLike(object) ? arrayLikeKeys(object) : baseKeys(object);
  14057. }
  14058. /**
  14059. * Creates an array of the own and inherited enumerable property names of `object`.
  14060. *
  14061. * **Note:** Non-object values are coerced to objects.
  14062. *
  14063. * @static
  14064. * @memberOf _
  14065. * @since 3.0.0
  14066. * @category Object
  14067. * @param {Object} object The object to query.
  14068. * @returns {Array} Returns the array of property names.
  14069. * @example
  14070. *
  14071. * function Foo() {
  14072. * this.a = 1;
  14073. * this.b = 2;
  14074. * }
  14075. *
  14076. * Foo.prototype.c = 3;
  14077. *
  14078. * _.keysIn(new Foo);
  14079. * // => ['a', 'b', 'c'] (iteration order is not guaranteed)
  14080. */
  14081. function keysIn(object) {
  14082. return isArrayLike(object) ? arrayLikeKeys(object, true) : baseKeysIn(object);
  14083. }
  14084. /**
  14085. * The opposite of `_.mapValues`; this method creates an object with the
  14086. * same values as `object` and keys generated by running each own enumerable
  14087. * string keyed property of `object` thru `iteratee`. The iteratee is invoked
  14088. * with three arguments: (value, key, object).
  14089. *
  14090. * @static
  14091. * @memberOf _
  14092. * @since 3.8.0
  14093. * @category Object
  14094. * @param {Object} object The object to iterate over.
  14095. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  14096. * @returns {Object} Returns the new mapped object.
  14097. * @see _.mapValues
  14098. * @example
  14099. *
  14100. * _.mapKeys({ 'a': 1, 'b': 2 }, function(value, key) {
  14101. * return key + value;
  14102. * });
  14103. * // => { 'a1': 1, 'b2': 2 }
  14104. */
  14105. function mapKeys(object, iteratee) {
  14106. var result = {};
  14107. iteratee = getIteratee(iteratee, 3);
  14108. baseForOwn(object, function(value, key, object) {
  14109. baseAssignValue(result, iteratee(value, key, object), value);
  14110. });
  14111. return result;
  14112. }
  14113. /**
  14114. * Creates an object with the same keys as `object` and values generated
  14115. * by running each own enumerable string keyed property of `object` thru
  14116. * `iteratee`. The iteratee is invoked with three arguments:
  14117. * (value, key, object).
  14118. *
  14119. * @static
  14120. * @memberOf _
  14121. * @since 2.4.0
  14122. * @category Object
  14123. * @param {Object} object The object to iterate over.
  14124. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  14125. * @returns {Object} Returns the new mapped object.
  14126. * @see _.mapKeys
  14127. * @example
  14128. *
  14129. * var users = {
  14130. * 'fred': { 'user': 'fred', 'age': 40 },
  14131. * 'pebbles': { 'user': 'pebbles', 'age': 1 }
  14132. * };
  14133. *
  14134. * _.mapValues(users, function(o) { return o.age; });
  14135. * // => { 'fred': 40, 'pebbles': 1 } (iteration order is not guaranteed)
  14136. *
  14137. * // The `_.property` iteratee shorthand.
  14138. * _.mapValues(users, 'age');
  14139. * // => { 'fred': 40, 'pebbles': 1 } (iteration order is not guaranteed)
  14140. */
  14141. function mapValues(object, iteratee) {
  14142. var result = {};
  14143. iteratee = getIteratee(iteratee, 3);
  14144. baseForOwn(object, function(value, key, object) {
  14145. baseAssignValue(result, key, iteratee(value, key, object));
  14146. });
  14147. return result;
  14148. }
  14149. /**
  14150. * This method is like `_.assign` except that it recursively merges own and
  14151. * inherited enumerable string keyed properties of source objects into the
  14152. * destination object. Source properties that resolve to `undefined` are
  14153. * skipped if a destination value exists. Array and plain object properties
  14154. * are merged recursively. Other objects and value types are overridden by
  14155. * assignment. Source objects are applied from left to right. Subsequent
  14156. * sources overwrite property assignments of previous sources.
  14157. *
  14158. * **Note:** This method mutates `object`.
  14159. *
  14160. * @static
  14161. * @memberOf _
  14162. * @since 0.5.0
  14163. * @category Object
  14164. * @param {Object} object The destination object.
  14165. * @param {...Object} [sources] The source objects.
  14166. * @returns {Object} Returns `object`.
  14167. * @example
  14168. *
  14169. * var object = {
  14170. * 'a': [{ 'b': 2 }, { 'd': 4 }]
  14171. * };
  14172. *
  14173. * var other = {
  14174. * 'a': [{ 'c': 3 }, { 'e': 5 }]
  14175. * };
  14176. *
  14177. * _.merge(object, other);
  14178. * // => { 'a': [{ 'b': 2, 'c': 3 }, { 'd': 4, 'e': 5 }] }
  14179. */
  14180. var merge = createAssigner(function(object, source, srcIndex) {
  14181. baseMerge(object, source, srcIndex);
  14182. });
  14183. /**
  14184. * This method is like `_.merge` except that it accepts `customizer` which
  14185. * is invoked to produce the merged values of the destination and source
  14186. * properties. If `customizer` returns `undefined`, merging is handled by the
  14187. * method instead. The `customizer` is invoked with six arguments:
  14188. * (objValue, srcValue, key, object, source, stack).
  14189. *
  14190. * **Note:** This method mutates `object`.
  14191. *
  14192. * @static
  14193. * @memberOf _
  14194. * @since 4.0.0
  14195. * @category Object
  14196. * @param {Object} object The destination object.
  14197. * @param {...Object} sources The source objects.
  14198. * @param {Function} customizer The function to customize assigned values.
  14199. * @returns {Object} Returns `object`.
  14200. * @example
  14201. *
  14202. * function customizer(objValue, srcValue) {
  14203. * if (_.isArray(objValue)) {
  14204. * return objValue.concat(srcValue);
  14205. * }
  14206. * }
  14207. *
  14208. * var object = { 'a': [1], 'b': [2] };
  14209. * var other = { 'a': [3], 'b': [4] };
  14210. *
  14211. * _.mergeWith(object, other, customizer);
  14212. * // => { 'a': [1, 3], 'b': [2, 4] }
  14213. */
  14214. var mergeWith = createAssigner(function(object, source, srcIndex, customizer) {
  14215. baseMerge(object, source, srcIndex, customizer);
  14216. });
  14217. /**
  14218. * The opposite of `_.pick`; this method creates an object composed of the
  14219. * own and inherited enumerable property paths of `object` that are not omitted.
  14220. *
  14221. * **Note:** This method is considerably slower than `_.pick`.
  14222. *
  14223. * @static
  14224. * @since 0.1.0
  14225. * @memberOf _
  14226. * @category Object
  14227. * @param {Object} object The source object.
  14228. * @param {...(string|string[])} [paths] The property paths to omit.
  14229. * @returns {Object} Returns the new object.
  14230. * @example
  14231. *
  14232. * var object = { 'a': 1, 'b': '2', 'c': 3 };
  14233. *
  14234. * _.omit(object, ['a', 'c']);
  14235. * // => { 'b': '2' }
  14236. */
  14237. var omit = flatRest(function(object, paths) {
  14238. var result = {};
  14239. if (object == null) {
  14240. return result;
  14241. }
  14242. var isDeep = false;
  14243. paths = arrayMap(paths, function(path) {
  14244. path = castPath(path, object);
  14245. isDeep || (isDeep = path.length > 1);
  14246. return path;
  14247. });
  14248. copyObject(object, getAllKeysIn(object), result);
  14249. if (isDeep) {
  14250. result = baseClone(result, CLONE_DEEP_FLAG | CLONE_FLAT_FLAG | CLONE_SYMBOLS_FLAG, customOmitClone);
  14251. }
  14252. var length = paths.length;
  14253. while (length--) {
  14254. baseUnset(result, paths[length]);
  14255. }
  14256. return result;
  14257. });
  14258. /**
  14259. * The opposite of `_.pickBy`; this method creates an object composed of
  14260. * the own and inherited enumerable string keyed properties of `object` that
  14261. * `predicate` doesn't return truthy for. The predicate is invoked with two
  14262. * arguments: (value, key).
  14263. *
  14264. * @static
  14265. * @memberOf _
  14266. * @since 4.0.0
  14267. * @category Object
  14268. * @param {Object} object The source object.
  14269. * @param {Function} [predicate=_.identity] The function invoked per property.
  14270. * @returns {Object} Returns the new object.
  14271. * @example
  14272. *
  14273. * var object = { 'a': 1, 'b': '2', 'c': 3 };
  14274. *
  14275. * _.omitBy(object, _.isNumber);
  14276. * // => { 'b': '2' }
  14277. */
  14278. function omitBy(object, predicate) {
  14279. return pickBy(object, negate(getIteratee(predicate)));
  14280. }
  14281. /**
  14282. * Creates an object composed of the picked `object` properties.
  14283. *
  14284. * @static
  14285. * @since 0.1.0
  14286. * @memberOf _
  14287. * @category Object
  14288. * @param {Object} object The source object.
  14289. * @param {...(string|string[])} [paths] The property paths to pick.
  14290. * @returns {Object} Returns the new object.
  14291. * @example
  14292. *
  14293. * var object = { 'a': 1, 'b': '2', 'c': 3 };
  14294. *
  14295. * _.pick(object, ['a', 'c']);
  14296. * // => { 'a': 1, 'c': 3 }
  14297. */
  14298. var pick = flatRest(function(object, paths) {
  14299. return object == null ? {} : basePick(object, paths);
  14300. });
  14301. /**
  14302. * Creates an object composed of the `object` properties `predicate` returns
  14303. * truthy for. The predicate is invoked with two arguments: (value, key).
  14304. *
  14305. * @static
  14306. * @memberOf _
  14307. * @since 4.0.0
  14308. * @category Object
  14309. * @param {Object} object The source object.
  14310. * @param {Function} [predicate=_.identity] The function invoked per property.
  14311. * @returns {Object} Returns the new object.
  14312. * @example
  14313. *
  14314. * var object = { 'a': 1, 'b': '2', 'c': 3 };
  14315. *
  14316. * _.pickBy(object, _.isNumber);
  14317. * // => { 'a': 1, 'c': 3 }
  14318. */
  14319. function pickBy(object, predicate) {
  14320. if (object == null) {
  14321. return {};
  14322. }
  14323. var props = arrayMap(getAllKeysIn(object), function(prop) {
  14324. return [prop];
  14325. });
  14326. predicate = getIteratee(predicate);
  14327. return basePickBy(object, props, function(value, path) {
  14328. return predicate(value, path[0]);
  14329. });
  14330. }
  14331. /**
  14332. * This method is like `_.get` except that if the resolved value is a
  14333. * function it's invoked with the `this` binding of its parent object and
  14334. * its result is returned.
  14335. *
  14336. * @static
  14337. * @since 0.1.0
  14338. * @memberOf _
  14339. * @category Object
  14340. * @param {Object} object The object to query.
  14341. * @param {Array|string} path The path of the property to resolve.
  14342. * @param {*} [defaultValue] The value returned for `undefined` resolved values.
  14343. * @returns {*} Returns the resolved value.
  14344. * @example
  14345. *
  14346. * var object = { 'a': [{ 'b': { 'c1': 3, 'c2': _.constant(4) } }] };
  14347. *
  14348. * _.result(object, 'a[0].b.c1');
  14349. * // => 3
  14350. *
  14351. * _.result(object, 'a[0].b.c2');
  14352. * // => 4
  14353. *
  14354. * _.result(object, 'a[0].b.c3', 'default');
  14355. * // => 'default'
  14356. *
  14357. * _.result(object, 'a[0].b.c3', _.constant('default'));
  14358. * // => 'default'
  14359. */
  14360. function result(object, path, defaultValue) {
  14361. path = castPath(path, object);
  14362. var index = -1,
  14363. length = path.length;
  14364. // Ensure the loop is entered when path is empty.
  14365. if (!length) {
  14366. length = 1;
  14367. object = undefined;
  14368. }
  14369. while (++index < length) {
  14370. var value = object == null ? undefined : object[toKey(path[index])];
  14371. if (value === undefined) {
  14372. index = length;
  14373. value = defaultValue;
  14374. }
  14375. object = isFunction(value) ? value.call(object) : value;
  14376. }
  14377. return object;
  14378. }
  14379. /**
  14380. * Sets the value at `path` of `object`. If a portion of `path` doesn't exist,
  14381. * it's created. Arrays are created for missing index properties while objects
  14382. * are created for all other missing properties. Use `_.setWith` to customize
  14383. * `path` creation.
  14384. *
  14385. * **Note:** This method mutates `object`.
  14386. *
  14387. * @static
  14388. * @memberOf _
  14389. * @since 3.7.0
  14390. * @category Object
  14391. * @param {Object} object The object to modify.
  14392. * @param {Array|string} path The path of the property to set.
  14393. * @param {*} value The value to set.
  14394. * @returns {Object} Returns `object`.
  14395. * @example
  14396. *
  14397. * var object = { 'a': [{ 'b': { 'c': 3 } }] };
  14398. *
  14399. * _.set(object, 'a[0].b.c', 4);
  14400. * console.log(object.a[0].b.c);
  14401. * // => 4
  14402. *
  14403. * _.set(object, ['x', '0', 'y', 'z'], 5);
  14404. * console.log(object.x[0].y.z);
  14405. * // => 5
  14406. */
  14407. function set(object, path, value) {
  14408. return object == null ? object : baseSet(object, path, value);
  14409. }
  14410. /**
  14411. * This method is like `_.set` except that it accepts `customizer` which is
  14412. * invoked to produce the objects of `path`. If `customizer` returns `undefined`
  14413. * path creation is handled by the method instead. The `customizer` is invoked
  14414. * with three arguments: (nsValue, key, nsObject).
  14415. *
  14416. * **Note:** This method mutates `object`.
  14417. *
  14418. * @static
  14419. * @memberOf _
  14420. * @since 4.0.0
  14421. * @category Object
  14422. * @param {Object} object The object to modify.
  14423. * @param {Array|string} path The path of the property to set.
  14424. * @param {*} value The value to set.
  14425. * @param {Function} [customizer] The function to customize assigned values.
  14426. * @returns {Object} Returns `object`.
  14427. * @example
  14428. *
  14429. * var object = {};
  14430. *
  14431. * _.setWith(object, '[0][1]', 'a', Object);
  14432. * // => { '0': { '1': 'a' } }
  14433. */
  14434. function setWith(object, path, value, customizer) {
  14435. customizer = typeof customizer == 'function' ? customizer : undefined;
  14436. return object == null ? object : baseSet(object, path, value, customizer);
  14437. }
  14438. /**
  14439. * Creates an array of own enumerable string keyed-value pairs for `object`
  14440. * which can be consumed by `_.fromPairs`. If `object` is a map or set, its
  14441. * entries are returned.
  14442. *
  14443. * @static
  14444. * @memberOf _
  14445. * @since 4.0.0
  14446. * @alias entries
  14447. * @category Object
  14448. * @param {Object} object The object to query.
  14449. * @returns {Array} Returns the key-value pairs.
  14450. * @example
  14451. *
  14452. * function Foo() {
  14453. * this.a = 1;
  14454. * this.b = 2;
  14455. * }
  14456. *
  14457. * Foo.prototype.c = 3;
  14458. *
  14459. * _.toPairs(new Foo);
  14460. * // => [['a', 1], ['b', 2]] (iteration order is not guaranteed)
  14461. */
  14462. var toPairs = createToPairs(keys);
  14463. /**
  14464. * Creates an array of own and inherited enumerable string keyed-value pairs
  14465. * for `object` which can be consumed by `_.fromPairs`. If `object` is a map
  14466. * or set, its entries are returned.
  14467. *
  14468. * @static
  14469. * @memberOf _
  14470. * @since 4.0.0
  14471. * @alias entriesIn
  14472. * @category Object
  14473. * @param {Object} object The object to query.
  14474. * @returns {Array} Returns the key-value pairs.
  14475. * @example
  14476. *
  14477. * function Foo() {
  14478. * this.a = 1;
  14479. * this.b = 2;
  14480. * }
  14481. *
  14482. * Foo.prototype.c = 3;
  14483. *
  14484. * _.toPairsIn(new Foo);
  14485. * // => [['a', 1], ['b', 2], ['c', 3]] (iteration order is not guaranteed)
  14486. */
  14487. var toPairsIn = createToPairs(keysIn);
  14488. /**
  14489. * An alternative to `_.reduce`; this method transforms `object` to a new
  14490. * `accumulator` object which is the result of running each of its own
  14491. * enumerable string keyed properties thru `iteratee`, with each invocation
  14492. * potentially mutating the `accumulator` object. If `accumulator` is not
  14493. * provided, a new object with the same `[[Prototype]]` will be used. The
  14494. * iteratee is invoked with four arguments: (accumulator, value, key, object).
  14495. * Iteratee functions may exit iteration early by explicitly returning `false`.
  14496. *
  14497. * @static
  14498. * @memberOf _
  14499. * @since 1.3.0
  14500. * @category Object
  14501. * @param {Object} object The object to iterate over.
  14502. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  14503. * @param {*} [accumulator] The custom accumulator value.
  14504. * @returns {*} Returns the accumulated value.
  14505. * @example
  14506. *
  14507. * _.transform([2, 3, 4], function(result, n) {
  14508. * result.push(n *= n);
  14509. * return n % 2 == 0;
  14510. * }, []);
  14511. * // => [4, 9]
  14512. *
  14513. * _.transform({ 'a': 1, 'b': 2, 'c': 1 }, function(result, value, key) {
  14514. * (result[value] || (result[value] = [])).push(key);
  14515. * }, {});
  14516. * // => { '1': ['a', 'c'], '2': ['b'] }
  14517. */
  14518. function transform(object, iteratee, accumulator) {
  14519. var isArr = isArray(object),
  14520. isArrLike = isArr || isBuffer(object) || isTypedArray(object);
  14521. iteratee = getIteratee(iteratee, 4);
  14522. if (accumulator == null) {
  14523. var Ctor = object && object.constructor;
  14524. if (isArrLike) {
  14525. accumulator = isArr ? new Ctor : [];
  14526. }
  14527. else if (isObject(object)) {
  14528. accumulator = isFunction(Ctor) ? baseCreate(getPrototype(object)) : {};
  14529. }
  14530. else {
  14531. accumulator = {};
  14532. }
  14533. }
  14534. (isArrLike ? arrayEach : baseForOwn)(object, function(value, index, object) {
  14535. return iteratee(accumulator, value, index, object);
  14536. });
  14537. return accumulator;
  14538. }
  14539. /**
  14540. * Removes the property at `path` of `object`.
  14541. *
  14542. * **Note:** This method mutates `object`.
  14543. *
  14544. * @static
  14545. * @memberOf _
  14546. * @since 4.0.0
  14547. * @category Object
  14548. * @param {Object} object The object to modify.
  14549. * @param {Array|string} path The path of the property to unset.
  14550. * @returns {boolean} Returns `true` if the property is deleted, else `false`.
  14551. * @example
  14552. *
  14553. * var object = { 'a': [{ 'b': { 'c': 7 } }] };
  14554. * _.unset(object, 'a[0].b.c');
  14555. * // => true
  14556. *
  14557. * console.log(object);
  14558. * // => { 'a': [{ 'b': {} }] };
  14559. *
  14560. * _.unset(object, ['a', '0', 'b', 'c']);
  14561. * // => true
  14562. *
  14563. * console.log(object);
  14564. * // => { 'a': [{ 'b': {} }] };
  14565. */
  14566. function unset(object, path) {
  14567. return object == null ? true : baseUnset(object, path);
  14568. }
  14569. /**
  14570. * This method is like `_.set` except that accepts `updater` to produce the
  14571. * value to set. Use `_.updateWith` to customize `path` creation. The `updater`
  14572. * is invoked with one argument: (value).
  14573. *
  14574. * **Note:** This method mutates `object`.
  14575. *
  14576. * @static
  14577. * @memberOf _
  14578. * @since 4.6.0
  14579. * @category Object
  14580. * @param {Object} object The object to modify.
  14581. * @param {Array|string} path The path of the property to set.
  14582. * @param {Function} updater The function to produce the updated value.
  14583. * @returns {Object} Returns `object`.
  14584. * @example
  14585. *
  14586. * var object = { 'a': [{ 'b': { 'c': 3 } }] };
  14587. *
  14588. * _.update(object, 'a[0].b.c', function(n) { return n * n; });
  14589. * console.log(object.a[0].b.c);
  14590. * // => 9
  14591. *
  14592. * _.update(object, 'x[0].y.z', function(n) { return n ? n + 1 : 0; });
  14593. * console.log(object.x[0].y.z);
  14594. * // => 0
  14595. */
  14596. function update(object, path, updater) {
  14597. return object == null ? object : baseUpdate(object, path, castFunction(updater));
  14598. }
  14599. /**
  14600. * This method is like `_.update` except that it accepts `customizer` which is
  14601. * invoked to produce the objects of `path`. If `customizer` returns `undefined`
  14602. * path creation is handled by the method instead. The `customizer` is invoked
  14603. * with three arguments: (nsValue, key, nsObject).
  14604. *
  14605. * **Note:** This method mutates `object`.
  14606. *
  14607. * @static
  14608. * @memberOf _
  14609. * @since 4.6.0
  14610. * @category Object
  14611. * @param {Object} object The object to modify.
  14612. * @param {Array|string} path The path of the property to set.
  14613. * @param {Function} updater The function to produce the updated value.
  14614. * @param {Function} [customizer] The function to customize assigned values.
  14615. * @returns {Object} Returns `object`.
  14616. * @example
  14617. *
  14618. * var object = {};
  14619. *
  14620. * _.updateWith(object, '[0][1]', _.constant('a'), Object);
  14621. * // => { '0': { '1': 'a' } }
  14622. */
  14623. function updateWith(object, path, updater, customizer) {
  14624. customizer = typeof customizer == 'function' ? customizer : undefined;
  14625. return object == null ? object : baseUpdate(object, path, castFunction(updater), customizer);
  14626. }
  14627. /**
  14628. * Creates an array of the own enumerable string keyed property values of `object`.
  14629. *
  14630. * **Note:** Non-object values are coerced to objects.
  14631. *
  14632. * @static
  14633. * @since 0.1.0
  14634. * @memberOf _
  14635. * @category Object
  14636. * @param {Object} object The object to query.
  14637. * @returns {Array} Returns the array of property values.
  14638. * @example
  14639. *
  14640. * function Foo() {
  14641. * this.a = 1;
  14642. * this.b = 2;
  14643. * }
  14644. *
  14645. * Foo.prototype.c = 3;
  14646. *
  14647. * _.values(new Foo);
  14648. * // => [1, 2] (iteration order is not guaranteed)
  14649. *
  14650. * _.values('hi');
  14651. * // => ['h', 'i']
  14652. */
  14653. function values(object) {
  14654. return object == null ? [] : baseValues(object, keys(object));
  14655. }
  14656. /**
  14657. * Creates an array of the own and inherited enumerable string keyed property
  14658. * values of `object`.
  14659. *
  14660. * **Note:** Non-object values are coerced to objects.
  14661. *
  14662. * @static
  14663. * @memberOf _
  14664. * @since 3.0.0
  14665. * @category Object
  14666. * @param {Object} object The object to query.
  14667. * @returns {Array} Returns the array of property values.
  14668. * @example
  14669. *
  14670. * function Foo() {
  14671. * this.a = 1;
  14672. * this.b = 2;
  14673. * }
  14674. *
  14675. * Foo.prototype.c = 3;
  14676. *
  14677. * _.valuesIn(new Foo);
  14678. * // => [1, 2, 3] (iteration order is not guaranteed)
  14679. */
  14680. function valuesIn(object) {
  14681. return object == null ? [] : baseValues(object, keysIn(object));
  14682. }
  14683. /*------------------------------------------------------------------------*/
  14684. /**
  14685. * Clamps `number` within the inclusive `lower` and `upper` bounds.
  14686. *
  14687. * @static
  14688. * @memberOf _
  14689. * @since 4.0.0
  14690. * @category Number
  14691. * @param {number} number The number to clamp.
  14692. * @param {number} [lower] The lower bound.
  14693. * @param {number} upper The upper bound.
  14694. * @returns {number} Returns the clamped number.
  14695. * @example
  14696. *
  14697. * _.clamp(-10, -5, 5);
  14698. * // => -5
  14699. *
  14700. * _.clamp(10, -5, 5);
  14701. * // => 5
  14702. */
  14703. function clamp(number, lower, upper) {
  14704. if (upper === undefined) {
  14705. upper = lower;
  14706. lower = undefined;
  14707. }
  14708. if (upper !== undefined) {
  14709. upper = toNumber(upper);
  14710. upper = upper === upper ? upper : 0;
  14711. }
  14712. if (lower !== undefined) {
  14713. lower = toNumber(lower);
  14714. lower = lower === lower ? lower : 0;
  14715. }
  14716. return baseClamp(toNumber(number), lower, upper);
  14717. }
  14718. /**
  14719. * Checks if `n` is between `start` and up to, but not including, `end`. If
  14720. * `end` is not specified, it's set to `start` with `start` then set to `0`.
  14721. * If `start` is greater than `end` the params are swapped to support
  14722. * negative ranges.
  14723. *
  14724. * @static
  14725. * @memberOf _
  14726. * @since 3.3.0
  14727. * @category Number
  14728. * @param {number} number The number to check.
  14729. * @param {number} [start=0] The start of the range.
  14730. * @param {number} end The end of the range.
  14731. * @returns {boolean} Returns `true` if `number` is in the range, else `false`.
  14732. * @see _.range, _.rangeRight
  14733. * @example
  14734. *
  14735. * _.inRange(3, 2, 4);
  14736. * // => true
  14737. *
  14738. * _.inRange(4, 8);
  14739. * // => true
  14740. *
  14741. * _.inRange(4, 2);
  14742. * // => false
  14743. *
  14744. * _.inRange(2, 2);
  14745. * // => false
  14746. *
  14747. * _.inRange(1.2, 2);
  14748. * // => true
  14749. *
  14750. * _.inRange(5.2, 4);
  14751. * // => false
  14752. *
  14753. * _.inRange(-3, -2, -6);
  14754. * // => true
  14755. */
  14756. function inRange(number, start, end) {
  14757. start = toFinite(start);
  14758. if (end === undefined) {
  14759. end = start;
  14760. start = 0;
  14761. } else {
  14762. end = toFinite(end);
  14763. }
  14764. number = toNumber(number);
  14765. return baseInRange(number, start, end);
  14766. }
  14767. /**
  14768. * Produces a random number between the inclusive `lower` and `upper` bounds.
  14769. * If only one argument is provided a number between `0` and the given number
  14770. * is returned. If `floating` is `true`, or either `lower` or `upper` are
  14771. * floats, a floating-point number is returned instead of an integer.
  14772. *
  14773. * **Note:** JavaScript follows the IEEE-754 standard for resolving
  14774. * floating-point values which can produce unexpected results.
  14775. *
  14776. * @static
  14777. * @memberOf _
  14778. * @since 0.7.0
  14779. * @category Number
  14780. * @param {number} [lower=0] The lower bound.
  14781. * @param {number} [upper=1] The upper bound.
  14782. * @param {boolean} [floating] Specify returning a floating-point number.
  14783. * @returns {number} Returns the random number.
  14784. * @example
  14785. *
  14786. * _.random(0, 5);
  14787. * // => an integer between 0 and 5
  14788. *
  14789. * _.random(5);
  14790. * // => also an integer between 0 and 5
  14791. *
  14792. * _.random(5, true);
  14793. * // => a floating-point number between 0 and 5
  14794. *
  14795. * _.random(1.2, 5.2);
  14796. * // => a floating-point number between 1.2 and 5.2
  14797. */
  14798. function random(lower, upper, floating) {
  14799. if (floating && typeof floating != 'boolean' && isIterateeCall(lower, upper, floating)) {
  14800. upper = floating = undefined;
  14801. }
  14802. if (floating === undefined) {
  14803. if (typeof upper == 'boolean') {
  14804. floating = upper;
  14805. upper = undefined;
  14806. }
  14807. else if (typeof lower == 'boolean') {
  14808. floating = lower;
  14809. lower = undefined;
  14810. }
  14811. }
  14812. if (lower === undefined && upper === undefined) {
  14813. lower = 0;
  14814. upper = 1;
  14815. }
  14816. else {
  14817. lower = toFinite(lower);
  14818. if (upper === undefined) {
  14819. upper = lower;
  14820. lower = 0;
  14821. } else {
  14822. upper = toFinite(upper);
  14823. }
  14824. }
  14825. if (lower > upper) {
  14826. var temp = lower;
  14827. lower = upper;
  14828. upper = temp;
  14829. }
  14830. if (floating || lower % 1 || upper % 1) {
  14831. var rand = nativeRandom();
  14832. return nativeMin(lower + (rand * (upper - lower + freeParseFloat('1e-' + ((rand + '').length - 1)))), upper);
  14833. }
  14834. return baseRandom(lower, upper);
  14835. }
  14836. /*------------------------------------------------------------------------*/
  14837. /**
  14838. * Converts `string` to [camel case](https://en.wikipedia.org/wiki/CamelCase).
  14839. *
  14840. * @static
  14841. * @memberOf _
  14842. * @since 3.0.0
  14843. * @category String
  14844. * @param {string} [string=''] The string to convert.
  14845. * @returns {string} Returns the camel cased string.
  14846. * @example
  14847. *
  14848. * _.camelCase('Foo Bar');
  14849. * // => 'fooBar'
  14850. *
  14851. * _.camelCase('--foo-bar--');
  14852. * // => 'fooBar'
  14853. *
  14854. * _.camelCase('__FOO_BAR__');
  14855. * // => 'fooBar'
  14856. */
  14857. var camelCase = createCompounder(function(result, word, index) {
  14858. word = word.toLowerCase();
  14859. return result + (index ? capitalize(word) : word);
  14860. });
  14861. /**
  14862. * Converts the first character of `string` to upper case and the remaining
  14863. * to lower case.
  14864. *
  14865. * @static
  14866. * @memberOf _
  14867. * @since 3.0.0
  14868. * @category String
  14869. * @param {string} [string=''] The string to capitalize.
  14870. * @returns {string} Returns the capitalized string.
  14871. * @example
  14872. *
  14873. * _.capitalize('FRED');
  14874. * // => 'Fred'
  14875. */
  14876. function capitalize(string) {
  14877. return upperFirst(toString(string).toLowerCase());
  14878. }
  14879. /**
  14880. * Deburrs `string` by converting
  14881. * [Latin-1 Supplement](https://en.wikipedia.org/wiki/Latin-1_Supplement_(Unicode_block)#Character_table)
  14882. * and [Latin Extended-A](https://en.wikipedia.org/wiki/Latin_Extended-A)
  14883. * letters to basic Latin letters and removing
  14884. * [combining diacritical marks](https://en.wikipedia.org/wiki/Combining_Diacritical_Marks).
  14885. *
  14886. * @static
  14887. * @memberOf _
  14888. * @since 3.0.0
  14889. * @category String
  14890. * @param {string} [string=''] The string to deburr.
  14891. * @returns {string} Returns the deburred string.
  14892. * @example
  14893. *
  14894. * _.deburr('déjà vu');
  14895. * // => 'deja vu'
  14896. */
  14897. function deburr(string) {
  14898. string = toString(string);
  14899. return string && string.replace(reLatin, deburrLetter).replace(reComboMark, '');
  14900. }
  14901. /**
  14902. * Checks if `string` ends with the given target string.
  14903. *
  14904. * @static
  14905. * @memberOf _
  14906. * @since 3.0.0
  14907. * @category String
  14908. * @param {string} [string=''] The string to inspect.
  14909. * @param {string} [target] The string to search for.
  14910. * @param {number} [position=string.length] The position to search up to.
  14911. * @returns {boolean} Returns `true` if `string` ends with `target`,
  14912. * else `false`.
  14913. * @example
  14914. *
  14915. * _.endsWith('abc', 'c');
  14916. * // => true
  14917. *
  14918. * _.endsWith('abc', 'b');
  14919. * // => false
  14920. *
  14921. * _.endsWith('abc', 'b', 2);
  14922. * // => true
  14923. */
  14924. function endsWith(string, target, position) {
  14925. string = toString(string);
  14926. target = baseToString(target);
  14927. var length = string.length;
  14928. position = position === undefined
  14929. ? length
  14930. : baseClamp(toInteger(position), 0, length);
  14931. var end = position;
  14932. position -= target.length;
  14933. return position >= 0 && string.slice(position, end) == target;
  14934. }
  14935. /**
  14936. * Converts the characters "&", "<", ">", '"', and "'" in `string` to their
  14937. * corresponding HTML entities.
  14938. *
  14939. * **Note:** No other characters are escaped. To escape additional
  14940. * characters use a third-party library like [_he_](https://mths.be/he).
  14941. *
  14942. * Though the ">" character is escaped for symmetry, characters like
  14943. * ">" and "/" don't need escaping in HTML and have no special meaning
  14944. * unless they're part of a tag or unquoted attribute value. See
  14945. * [Mathias Bynens's article](https://mathiasbynens.be/notes/ambiguous-ampersands)
  14946. * (under "semi-related fun fact") for more details.
  14947. *
  14948. * When working with HTML you should always
  14949. * [quote attribute values](http://wonko.com/post/html-escaping) to reduce
  14950. * XSS vectors.
  14951. *
  14952. * @static
  14953. * @since 0.1.0
  14954. * @memberOf _
  14955. * @category String
  14956. * @param {string} [string=''] The string to escape.
  14957. * @returns {string} Returns the escaped string.
  14958. * @example
  14959. *
  14960. * _.escape('fred, barney, & pebbles');
  14961. * // => 'fred, barney, &amp; pebbles'
  14962. */
  14963. function escape(string) {
  14964. string = toString(string);
  14965. return (string && reHasUnescapedHtml.test(string))
  14966. ? string.replace(reUnescapedHtml, escapeHtmlChar)
  14967. : string;
  14968. }
  14969. /**
  14970. * Escapes the `RegExp` special characters "^", "$", "\", ".", "*", "+",
  14971. * "?", "(", ")", "[", "]", "{", "}", and "|" in `string`.
  14972. *
  14973. * @static
  14974. * @memberOf _
  14975. * @since 3.0.0
  14976. * @category String
  14977. * @param {string} [string=''] The string to escape.
  14978. * @returns {string} Returns the escaped string.
  14979. * @example
  14980. *
  14981. * _.escapeRegExp('[lodash](https://lodash.com/)');
  14982. * // => '\[lodash\]\(https://lodash\.com/\)'
  14983. */
  14984. function escapeRegExp(string) {
  14985. string = toString(string);
  14986. return (string && reHasRegExpChar.test(string))
  14987. ? string.replace(reRegExpChar, '\\$&')
  14988. : string;
  14989. }
  14990. /**
  14991. * Converts `string` to
  14992. * [kebab case](https://en.wikipedia.org/wiki/Letter_case#Special_case_styles).
  14993. *
  14994. * @static
  14995. * @memberOf _
  14996. * @since 3.0.0
  14997. * @category String
  14998. * @param {string} [string=''] The string to convert.
  14999. * @returns {string} Returns the kebab cased string.
  15000. * @example
  15001. *
  15002. * _.kebabCase('Foo Bar');
  15003. * // => 'foo-bar'
  15004. *
  15005. * _.kebabCase('fooBar');
  15006. * // => 'foo-bar'
  15007. *
  15008. * _.kebabCase('__FOO_BAR__');
  15009. * // => 'foo-bar'
  15010. */
  15011. var kebabCase = createCompounder(function(result, word, index) {
  15012. return result + (index ? '-' : '') + word.toLowerCase();
  15013. });
  15014. /**
  15015. * Converts `string`, as space separated words, to lower case.
  15016. *
  15017. * @static
  15018. * @memberOf _
  15019. * @since 4.0.0
  15020. * @category String
  15021. * @param {string} [string=''] The string to convert.
  15022. * @returns {string} Returns the lower cased string.
  15023. * @example
  15024. *
  15025. * _.lowerCase('--Foo-Bar--');
  15026. * // => 'foo bar'
  15027. *
  15028. * _.lowerCase('fooBar');
  15029. * // => 'foo bar'
  15030. *
  15031. * _.lowerCase('__FOO_BAR__');
  15032. * // => 'foo bar'
  15033. */
  15034. var lowerCase = createCompounder(function(result, word, index) {
  15035. return result + (index ? ' ' : '') + word.toLowerCase();
  15036. });
  15037. /**
  15038. * Converts the first character of `string` to lower case.
  15039. *
  15040. * @static
  15041. * @memberOf _
  15042. * @since 4.0.0
  15043. * @category String
  15044. * @param {string} [string=''] The string to convert.
  15045. * @returns {string} Returns the converted string.
  15046. * @example
  15047. *
  15048. * _.lowerFirst('Fred');
  15049. * // => 'fred'
  15050. *
  15051. * _.lowerFirst('FRED');
  15052. * // => 'fRED'
  15053. */
  15054. var lowerFirst = createCaseFirst('toLowerCase');
  15055. /**
  15056. * Pads `string` on the left and right sides if it's shorter than `length`.
  15057. * Padding characters are truncated if they can't be evenly divided by `length`.
  15058. *
  15059. * @static
  15060. * @memberOf _
  15061. * @since 3.0.0
  15062. * @category String
  15063. * @param {string} [string=''] The string to pad.
  15064. * @param {number} [length=0] The padding length.
  15065. * @param {string} [chars=' '] The string used as padding.
  15066. * @returns {string} Returns the padded string.
  15067. * @example
  15068. *
  15069. * _.pad('abc', 8);
  15070. * // => ' abc '
  15071. *
  15072. * _.pad('abc', 8, '_-');
  15073. * // => '_-abc_-_'
  15074. *
  15075. * _.pad('abc', 3);
  15076. * // => 'abc'
  15077. */
  15078. function pad(string, length, chars) {
  15079. string = toString(string);
  15080. length = toInteger(length);
  15081. var strLength = length ? stringSize(string) : 0;
  15082. if (!length || strLength >= length) {
  15083. return string;
  15084. }
  15085. var mid = (length - strLength) / 2;
  15086. return (
  15087. createPadding(nativeFloor(mid), chars) +
  15088. string +
  15089. createPadding(nativeCeil(mid), chars)
  15090. );
  15091. }
  15092. /**
  15093. * Pads `string` on the right side if it's shorter than `length`. Padding
  15094. * characters are truncated if they exceed `length`.
  15095. *
  15096. * @static
  15097. * @memberOf _
  15098. * @since 4.0.0
  15099. * @category String
  15100. * @param {string} [string=''] The string to pad.
  15101. * @param {number} [length=0] The padding length.
  15102. * @param {string} [chars=' '] The string used as padding.
  15103. * @returns {string} Returns the padded string.
  15104. * @example
  15105. *
  15106. * _.padEnd('abc', 6);
  15107. * // => 'abc '
  15108. *
  15109. * _.padEnd('abc', 6, '_-');
  15110. * // => 'abc_-_'
  15111. *
  15112. * _.padEnd('abc', 3);
  15113. * // => 'abc'
  15114. */
  15115. function padEnd(string, length, chars) {
  15116. string = toString(string);
  15117. length = toInteger(length);
  15118. var strLength = length ? stringSize(string) : 0;
  15119. return (length && strLength < length)
  15120. ? (string + createPadding(length - strLength, chars))
  15121. : string;
  15122. }
  15123. /**
  15124. * Pads `string` on the left side if it's shorter than `length`. Padding
  15125. * characters are truncated if they exceed `length`.
  15126. *
  15127. * @static
  15128. * @memberOf _
  15129. * @since 4.0.0
  15130. * @category String
  15131. * @param {string} [string=''] The string to pad.
  15132. * @param {number} [length=0] The padding length.
  15133. * @param {string} [chars=' '] The string used as padding.
  15134. * @returns {string} Returns the padded string.
  15135. * @example
  15136. *
  15137. * _.padStart('abc', 6);
  15138. * // => ' abc'
  15139. *
  15140. * _.padStart('abc', 6, '_-');
  15141. * // => '_-_abc'
  15142. *
  15143. * _.padStart('abc', 3);
  15144. * // => 'abc'
  15145. */
  15146. function padStart(string, length, chars) {
  15147. string = toString(string);
  15148. length = toInteger(length);
  15149. var strLength = length ? stringSize(string) : 0;
  15150. return (length && strLength < length)
  15151. ? (createPadding(length - strLength, chars) + string)
  15152. : string;
  15153. }
  15154. /**
  15155. * Converts `string` to an integer of the specified radix. If `radix` is
  15156. * `undefined` or `0`, a `radix` of `10` is used unless `value` is a
  15157. * hexadecimal, in which case a `radix` of `16` is used.
  15158. *
  15159. * **Note:** This method aligns with the
  15160. * [ES5 implementation](https://es5.github.io/#x15.1.2.2) of `parseInt`.
  15161. *
  15162. * @static
  15163. * @memberOf _
  15164. * @since 1.1.0
  15165. * @category String
  15166. * @param {string} string The string to convert.
  15167. * @param {number} [radix=10] The radix to interpret `value` by.
  15168. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  15169. * @returns {number} Returns the converted integer.
  15170. * @example
  15171. *
  15172. * _.parseInt('08');
  15173. * // => 8
  15174. *
  15175. * _.map(['6', '08', '10'], _.parseInt);
  15176. * // => [6, 8, 10]
  15177. */
  15178. function parseInt(string, radix, guard) {
  15179. if (guard || radix == null) {
  15180. radix = 0;
  15181. } else if (radix) {
  15182. radix = +radix;
  15183. }
  15184. return nativeParseInt(toString(string).replace(reTrimStart, ''), radix || 0);
  15185. }
  15186. /**
  15187. * Repeats the given string `n` times.
  15188. *
  15189. * @static
  15190. * @memberOf _
  15191. * @since 3.0.0
  15192. * @category String
  15193. * @param {string} [string=''] The string to repeat.
  15194. * @param {number} [n=1] The number of times to repeat the string.
  15195. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  15196. * @returns {string} Returns the repeated string.
  15197. * @example
  15198. *
  15199. * _.repeat('*', 3);
  15200. * // => '***'
  15201. *
  15202. * _.repeat('abc', 2);
  15203. * // => 'abcabc'
  15204. *
  15205. * _.repeat('abc', 0);
  15206. * // => ''
  15207. */
  15208. function repeat(string, n, guard) {
  15209. if ((guard ? isIterateeCall(string, n, guard) : n === undefined)) {
  15210. n = 1;
  15211. } else {
  15212. n = toInteger(n);
  15213. }
  15214. return baseRepeat(toString(string), n);
  15215. }
  15216. /**
  15217. * Replaces matches for `pattern` in `string` with `replacement`.
  15218. *
  15219. * **Note:** This method is based on
  15220. * [`String#replace`](https://mdn.io/String/replace).
  15221. *
  15222. * @static
  15223. * @memberOf _
  15224. * @since 4.0.0
  15225. * @category String
  15226. * @param {string} [string=''] The string to modify.
  15227. * @param {RegExp|string} pattern The pattern to replace.
  15228. * @param {Function|string} replacement The match replacement.
  15229. * @returns {string} Returns the modified string.
  15230. * @example
  15231. *
  15232. * _.replace('Hi Fred', 'Fred', 'Barney');
  15233. * // => 'Hi Barney'
  15234. */
  15235. function replace() {
  15236. var args = arguments,
  15237. string = toString(args[0]);
  15238. return args.length < 3 ? string : string.replace(args[1], args[2]);
  15239. }
  15240. /**
  15241. * Converts `string` to
  15242. * [snake case](https://en.wikipedia.org/wiki/Snake_case).
  15243. *
  15244. * @static
  15245. * @memberOf _
  15246. * @since 3.0.0
  15247. * @category String
  15248. * @param {string} [string=''] The string to convert.
  15249. * @returns {string} Returns the snake cased string.
  15250. * @example
  15251. *
  15252. * _.snakeCase('Foo Bar');
  15253. * // => 'foo_bar'
  15254. *
  15255. * _.snakeCase('fooBar');
  15256. * // => 'foo_bar'
  15257. *
  15258. * _.snakeCase('--FOO-BAR--');
  15259. * // => 'foo_bar'
  15260. */
  15261. var snakeCase = createCompounder(function(result, word, index) {
  15262. return result + (index ? '_' : '') + word.toLowerCase();
  15263. });
  15264. /**
  15265. * Splits `string` by `separator`.
  15266. *
  15267. * **Note:** This method is based on
  15268. * [`String#split`](https://mdn.io/String/split).
  15269. *
  15270. * @static
  15271. * @memberOf _
  15272. * @since 4.0.0
  15273. * @category String
  15274. * @param {string} [string=''] The string to split.
  15275. * @param {RegExp|string} separator The separator pattern to split by.
  15276. * @param {number} [limit] The length to truncate results to.
  15277. * @returns {Array} Returns the string segments.
  15278. * @example
  15279. *
  15280. * _.split('a-b-c', '-', 2);
  15281. * // => ['a', 'b']
  15282. */
  15283. function split(string, separator, limit) {
  15284. if (limit && typeof limit != 'number' && isIterateeCall(string, separator, limit)) {
  15285. separator = limit = undefined;
  15286. }
  15287. limit = limit === undefined ? MAX_ARRAY_LENGTH : limit >>> 0;
  15288. if (!limit) {
  15289. return [];
  15290. }
  15291. string = toString(string);
  15292. if (string && (
  15293. typeof separator == 'string' ||
  15294. (separator != null && !isRegExp(separator))
  15295. )) {
  15296. separator = baseToString(separator);
  15297. if (!separator && hasUnicode(string)) {
  15298. return castSlice(stringToArray(string), 0, limit);
  15299. }
  15300. }
  15301. return string.split(separator, limit);
  15302. }
  15303. /**
  15304. * Converts `string` to
  15305. * [start case](https://en.wikipedia.org/wiki/Letter_case#Stylistic_or_specialised_usage).
  15306. *
  15307. * @static
  15308. * @memberOf _
  15309. * @since 3.1.0
  15310. * @category String
  15311. * @param {string} [string=''] The string to convert.
  15312. * @returns {string} Returns the start cased string.
  15313. * @example
  15314. *
  15315. * _.startCase('--foo-bar--');
  15316. * // => 'Foo Bar'
  15317. *
  15318. * _.startCase('fooBar');
  15319. * // => 'Foo Bar'
  15320. *
  15321. * _.startCase('__FOO_BAR__');
  15322. * // => 'FOO BAR'
  15323. */
  15324. var startCase = createCompounder(function(result, word, index) {
  15325. return result + (index ? ' ' : '') + upperFirst(word);
  15326. });
  15327. /**
  15328. * Checks if `string` starts with the given target string.
  15329. *
  15330. * @static
  15331. * @memberOf _
  15332. * @since 3.0.0
  15333. * @category String
  15334. * @param {string} [string=''] The string to inspect.
  15335. * @param {string} [target] The string to search for.
  15336. * @param {number} [position=0] The position to search from.
  15337. * @returns {boolean} Returns `true` if `string` starts with `target`,
  15338. * else `false`.
  15339. * @example
  15340. *
  15341. * _.startsWith('abc', 'a');
  15342. * // => true
  15343. *
  15344. * _.startsWith('abc', 'b');
  15345. * // => false
  15346. *
  15347. * _.startsWith('abc', 'b', 1);
  15348. * // => true
  15349. */
  15350. function startsWith(string, target, position) {
  15351. string = toString(string);
  15352. position = position == null
  15353. ? 0
  15354. : baseClamp(toInteger(position), 0, string.length);
  15355. target = baseToString(target);
  15356. return string.slice(position, position + target.length) == target;
  15357. }
  15358. /**
  15359. * Creates a compiled template function that can interpolate data properties
  15360. * in "interpolate" delimiters, HTML-escape interpolated data properties in
  15361. * "escape" delimiters, and execute JavaScript in "evaluate" delimiters. Data
  15362. * properties may be accessed as free variables in the template. If a setting
  15363. * object is given, it takes precedence over `_.templateSettings` values.
  15364. *
  15365. * **Note:** In the development build `_.template` utilizes
  15366. * [sourceURLs](http://www.html5rocks.com/en/tutorials/developertools/sourcemaps/#toc-sourceurl)
  15367. * for easier debugging.
  15368. *
  15369. * For more information on precompiling templates see
  15370. * [lodash's custom builds documentation](https://lodash.com/custom-builds).
  15371. *
  15372. * For more information on Chrome extension sandboxes see
  15373. * [Chrome's extensions documentation](https://developer.chrome.com/extensions/sandboxingEval).
  15374. *
  15375. * @static
  15376. * @since 0.1.0
  15377. * @memberOf _
  15378. * @category String
  15379. * @param {string} [string=''] The template string.
  15380. * @param {Object} [options={}] The options object.
  15381. * @param {RegExp} [options.escape=_.templateSettings.escape]
  15382. * The HTML "escape" delimiter.
  15383. * @param {RegExp} [options.evaluate=_.templateSettings.evaluate]
  15384. * The "evaluate" delimiter.
  15385. * @param {Object} [options.imports=_.templateSettings.imports]
  15386. * An object to import into the template as free variables.
  15387. * @param {RegExp} [options.interpolate=_.templateSettings.interpolate]
  15388. * The "interpolate" delimiter.
  15389. * @param {string} [options.sourceURL='lodash.templateSources[n]']
  15390. * The sourceURL of the compiled template.
  15391. * @param {string} [options.variable='obj']
  15392. * The data object variable name.
  15393. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  15394. * @returns {Function} Returns the compiled template function.
  15395. * @example
  15396. *
  15397. * // Use the "interpolate" delimiter to create a compiled template.
  15398. * var compiled = _.template('hello <%= user %>!');
  15399. * compiled({ 'user': 'fred' });
  15400. * // => 'hello fred!'
  15401. *
  15402. * // Use the HTML "escape" delimiter to escape data property values.
  15403. * var compiled = _.template('<b><%- value %></b>');
  15404. * compiled({ 'value': '<script>' });
  15405. * // => '<b>&lt;script&gt;</b>'
  15406. *
  15407. * // Use the "evaluate" delimiter to execute JavaScript and generate HTML.
  15408. * var compiled = _.template('<% _.forEach(users, function(user) { %><li><%- user %></li><% }); %>');
  15409. * compiled({ 'users': ['fred', 'barney'] });
  15410. * // => '<li>fred</li><li>barney</li>'
  15411. *
  15412. * // Use the internal `print` function in "evaluate" delimiters.
  15413. * var compiled = _.template('<% print("hello " + user); %>!');
  15414. * compiled({ 'user': 'barney' });
  15415. * // => 'hello barney!'
  15416. *
  15417. * // Use the ES template literal delimiter as an "interpolate" delimiter.
  15418. * // Disable support by replacing the "interpolate" delimiter.
  15419. * var compiled = _.template('hello ${ user }!');
  15420. * compiled({ 'user': 'pebbles' });
  15421. * // => 'hello pebbles!'
  15422. *
  15423. * // Use backslashes to treat delimiters as plain text.
  15424. * var compiled = _.template('<%= "\\<%- value %\\>" %>');
  15425. * compiled({ 'value': 'ignored' });
  15426. * // => '<%- value %>'
  15427. *
  15428. * // Use the `imports` option to import `jQuery` as `jq`.
  15429. * var text = '<% jq.each(users, function(user) { %><li><%- user %></li><% }); %>';
  15430. * var compiled = _.template(text, { 'imports': { 'jq': jQuery } });
  15431. * compiled({ 'users': ['fred', 'barney'] });
  15432. * // => '<li>fred</li><li>barney</li>'
  15433. *
  15434. * // Use the `sourceURL` option to specify a custom sourceURL for the template.
  15435. * var compiled = _.template('hello <%= user %>!', { 'sourceURL': '/basic/greeting.jst' });
  15436. * compiled(data);
  15437. * // => Find the source of "greeting.jst" under the Sources tab or Resources panel of the web inspector.
  15438. *
  15439. * // Use the `variable` option to ensure a with-statement isn't used in the compiled template.
  15440. * var compiled = _.template('hi <%= data.user %>!', { 'variable': 'data' });
  15441. * compiled.source;
  15442. * // => function(data) {
  15443. * // var __t, __p = '';
  15444. * // __p += 'hi ' + ((__t = ( data.user )) == null ? '' : __t) + '!';
  15445. * // return __p;
  15446. * // }
  15447. *
  15448. * // Use custom template delimiters.
  15449. * _.templateSettings.interpolate = /{{([\s\S]+?)}}/g;
  15450. * var compiled = _.template('hello {{ user }}!');
  15451. * compiled({ 'user': 'mustache' });
  15452. * // => 'hello mustache!'
  15453. *
  15454. * // Use the `source` property to inline compiled templates for meaningful
  15455. * // line numbers in error messages and stack traces.
  15456. * fs.writeFileSync(path.join(process.cwd(), 'jst.js'), '\
  15457. * var JST = {\
  15458. * "main": ' + _.template(mainText).source + '\
  15459. * };\
  15460. * ');
  15461. */
  15462. function template(string, options, guard) {
  15463. // Based on John Resig's `tmpl` implementation
  15464. // (http://ejohn.org/blog/javascript-micro-templating/)
  15465. // and Laura Doktorova's doT.js (https://github.com/olado/doT).
  15466. var settings = lodash.templateSettings;
  15467. if (guard && isIterateeCall(string, options, guard)) {
  15468. options = undefined;
  15469. }
  15470. string = toString(string);
  15471. options = assignInWith({}, options, settings, customDefaultsAssignIn);
  15472. var imports = assignInWith({}, options.imports, settings.imports, customDefaultsAssignIn),
  15473. importsKeys = keys(imports),
  15474. importsValues = baseValues(imports, importsKeys);
  15475. var isEscaping,
  15476. isEvaluating,
  15477. index = 0,
  15478. interpolate = options.interpolate || reNoMatch,
  15479. source = "__p += '";
  15480. // Compile the regexp to match each delimiter.
  15481. var reDelimiters = RegExp(
  15482. (options.escape || reNoMatch).source + '|' +
  15483. interpolate.source + '|' +
  15484. (interpolate === reInterpolate ? reEsTemplate : reNoMatch).source + '|' +
  15485. (options.evaluate || reNoMatch).source + '|$'
  15486. , 'g');
  15487. // Use a sourceURL for easier debugging.
  15488. // The sourceURL gets injected into the source that's eval-ed, so be careful
  15489. // to normalize all kinds of whitespace, so e.g. newlines (and unicode versions of it) can't sneak in
  15490. // and escape the comment, thus injecting code that gets evaled.
  15491. var sourceURL = '//# sourceURL=' +
  15492. (hasOwnProperty.call(options, 'sourceURL')
  15493. ? (options.sourceURL + '').replace(/\s/g, ' ')
  15494. : ('lodash.templateSources[' + (++templateCounter) + ']')
  15495. ) + '\n';
  15496. string.replace(reDelimiters, function(match, escapeValue, interpolateValue, esTemplateValue, evaluateValue, offset) {
  15497. interpolateValue || (interpolateValue = esTemplateValue);
  15498. // Escape characters that can't be included in string literals.
  15499. source += string.slice(index, offset).replace(reUnescapedString, escapeStringChar);
  15500. // Replace delimiters with snippets.
  15501. if (escapeValue) {
  15502. isEscaping = true;
  15503. source += "' +\n__e(" + escapeValue + ") +\n'";
  15504. }
  15505. if (evaluateValue) {
  15506. isEvaluating = true;
  15507. source += "';\n" + evaluateValue + ";\n__p += '";
  15508. }
  15509. if (interpolateValue) {
  15510. source += "' +\n((__t = (" + interpolateValue + ")) == null ? '' : __t) +\n'";
  15511. }
  15512. index = offset + match.length;
  15513. // The JS engine embedded in Adobe products needs `match` returned in
  15514. // order to produce the correct `offset` value.
  15515. return match;
  15516. });
  15517. source += "';\n";
  15518. // If `variable` is not specified wrap a with-statement around the generated
  15519. // code to add the data object to the top of the scope chain.
  15520. var variable = hasOwnProperty.call(options, 'variable') && options.variable;
  15521. if (!variable) {
  15522. source = 'with (obj) {\n' + source + '\n}\n';
  15523. }
  15524. // Cleanup code by stripping empty strings.
  15525. source = (isEvaluating ? source.replace(reEmptyStringLeading, '') : source)
  15526. .replace(reEmptyStringMiddle, '$1')
  15527. .replace(reEmptyStringTrailing, '$1;');
  15528. // Frame code as the function body.
  15529. source = 'function(' + (variable || 'obj') + ') {\n' +
  15530. (variable
  15531. ? ''
  15532. : 'obj || (obj = {});\n'
  15533. ) +
  15534. "var __t, __p = ''" +
  15535. (isEscaping
  15536. ? ', __e = _.escape'
  15537. : ''
  15538. ) +
  15539. (isEvaluating
  15540. ? ', __j = Array.prototype.join;\n' +
  15541. "function print() { __p += __j.call(arguments, '') }\n"
  15542. : ';\n'
  15543. ) +
  15544. source +
  15545. 'return __p\n}';
  15546. var result = attempt(function() {
  15547. return Function(importsKeys, sourceURL + 'return ' + source)
  15548. .apply(undefined, importsValues);
  15549. });
  15550. // Provide the compiled function's source by its `toString` method or
  15551. // the `source` property as a convenience for inlining compiled templates.
  15552. result.source = source;
  15553. if (isError(result)) {
  15554. throw result;
  15555. }
  15556. return result;
  15557. }
  15558. /**
  15559. * Converts `string`, as a whole, to lower case just like
  15560. * [String#toLowerCase](https://mdn.io/toLowerCase).
  15561. *
  15562. * @static
  15563. * @memberOf _
  15564. * @since 4.0.0
  15565. * @category String
  15566. * @param {string} [string=''] The string to convert.
  15567. * @returns {string} Returns the lower cased string.
  15568. * @example
  15569. *
  15570. * _.toLower('--Foo-Bar--');
  15571. * // => '--foo-bar--'
  15572. *
  15573. * _.toLower('fooBar');
  15574. * // => 'foobar'
  15575. *
  15576. * _.toLower('__FOO_BAR__');
  15577. * // => '__foo_bar__'
  15578. */
  15579. function toLower(value) {
  15580. return toString(value).toLowerCase();
  15581. }
  15582. /**
  15583. * Converts `string`, as a whole, to upper case just like
  15584. * [String#toUpperCase](https://mdn.io/toUpperCase).
  15585. *
  15586. * @static
  15587. * @memberOf _
  15588. * @since 4.0.0
  15589. * @category String
  15590. * @param {string} [string=''] The string to convert.
  15591. * @returns {string} Returns the upper cased string.
  15592. * @example
  15593. *
  15594. * _.toUpper('--foo-bar--');
  15595. * // => '--FOO-BAR--'
  15596. *
  15597. * _.toUpper('fooBar');
  15598. * // => 'FOOBAR'
  15599. *
  15600. * _.toUpper('__foo_bar__');
  15601. * // => '__FOO_BAR__'
  15602. */
  15603. function toUpper(value) {
  15604. return toString(value).toUpperCase();
  15605. }
  15606. /**
  15607. * Removes leading and trailing whitespace or specified characters from `string`.
  15608. *
  15609. * @static
  15610. * @memberOf _
  15611. * @since 3.0.0
  15612. * @category String
  15613. * @param {string} [string=''] The string to trim.
  15614. * @param {string} [chars=whitespace] The characters to trim.
  15615. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  15616. * @returns {string} Returns the trimmed string.
  15617. * @example
  15618. *
  15619. * _.trim(' abc ');
  15620. * // => 'abc'
  15621. *
  15622. * _.trim('-_-abc-_-', '_-');
  15623. * // => 'abc'
  15624. *
  15625. * _.map([' foo ', ' bar '], _.trim);
  15626. * // => ['foo', 'bar']
  15627. */
  15628. function trim(string, chars, guard) {
  15629. string = toString(string);
  15630. if (string && (guard || chars === undefined)) {
  15631. return string.replace(reTrim, '');
  15632. }
  15633. if (!string || !(chars = baseToString(chars))) {
  15634. return string;
  15635. }
  15636. var strSymbols = stringToArray(string),
  15637. chrSymbols = stringToArray(chars),
  15638. start = charsStartIndex(strSymbols, chrSymbols),
  15639. end = charsEndIndex(strSymbols, chrSymbols) + 1;
  15640. return castSlice(strSymbols, start, end).join('');
  15641. }
  15642. /**
  15643. * Removes trailing whitespace or specified characters from `string`.
  15644. *
  15645. * @static
  15646. * @memberOf _
  15647. * @since 4.0.0
  15648. * @category String
  15649. * @param {string} [string=''] The string to trim.
  15650. * @param {string} [chars=whitespace] The characters to trim.
  15651. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  15652. * @returns {string} Returns the trimmed string.
  15653. * @example
  15654. *
  15655. * _.trimEnd(' abc ');
  15656. * // => ' abc'
  15657. *
  15658. * _.trimEnd('-_-abc-_-', '_-');
  15659. * // => '-_-abc'
  15660. */
  15661. function trimEnd(string, chars, guard) {
  15662. string = toString(string);
  15663. if (string && (guard || chars === undefined)) {
  15664. return string.replace(reTrimEnd, '');
  15665. }
  15666. if (!string || !(chars = baseToString(chars))) {
  15667. return string;
  15668. }
  15669. var strSymbols = stringToArray(string),
  15670. end = charsEndIndex(strSymbols, stringToArray(chars)) + 1;
  15671. return castSlice(strSymbols, 0, end).join('');
  15672. }
  15673. /**
  15674. * Removes leading whitespace or specified characters from `string`.
  15675. *
  15676. * @static
  15677. * @memberOf _
  15678. * @since 4.0.0
  15679. * @category String
  15680. * @param {string} [string=''] The string to trim.
  15681. * @param {string} [chars=whitespace] The characters to trim.
  15682. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  15683. * @returns {string} Returns the trimmed string.
  15684. * @example
  15685. *
  15686. * _.trimStart(' abc ');
  15687. * // => 'abc '
  15688. *
  15689. * _.trimStart('-_-abc-_-', '_-');
  15690. * // => 'abc-_-'
  15691. */
  15692. function trimStart(string, chars, guard) {
  15693. string = toString(string);
  15694. if (string && (guard || chars === undefined)) {
  15695. return string.replace(reTrimStart, '');
  15696. }
  15697. if (!string || !(chars = baseToString(chars))) {
  15698. return string;
  15699. }
  15700. var strSymbols = stringToArray(string),
  15701. start = charsStartIndex(strSymbols, stringToArray(chars));
  15702. return castSlice(strSymbols, start).join('');
  15703. }
  15704. /**
  15705. * Truncates `string` if it's longer than the given maximum string length.
  15706. * The last characters of the truncated string are replaced with the omission
  15707. * string which defaults to "...".
  15708. *
  15709. * @static
  15710. * @memberOf _
  15711. * @since 4.0.0
  15712. * @category String
  15713. * @param {string} [string=''] The string to truncate.
  15714. * @param {Object} [options={}] The options object.
  15715. * @param {number} [options.length=30] The maximum string length.
  15716. * @param {string} [options.omission='...'] The string to indicate text is omitted.
  15717. * @param {RegExp|string} [options.separator] The separator pattern to truncate to.
  15718. * @returns {string} Returns the truncated string.
  15719. * @example
  15720. *
  15721. * _.truncate('hi-diddly-ho there, neighborino');
  15722. * // => 'hi-diddly-ho there, neighbo...'
  15723. *
  15724. * _.truncate('hi-diddly-ho there, neighborino', {
  15725. * 'length': 24,
  15726. * 'separator': ' '
  15727. * });
  15728. * // => 'hi-diddly-ho there,...'
  15729. *
  15730. * _.truncate('hi-diddly-ho there, neighborino', {
  15731. * 'length': 24,
  15732. * 'separator': /,? +/
  15733. * });
  15734. * // => 'hi-diddly-ho there...'
  15735. *
  15736. * _.truncate('hi-diddly-ho there, neighborino', {
  15737. * 'omission': ' [...]'
  15738. * });
  15739. * // => 'hi-diddly-ho there, neig [...]'
  15740. */
  15741. function truncate(string, options) {
  15742. var length = DEFAULT_TRUNC_LENGTH,
  15743. omission = DEFAULT_TRUNC_OMISSION;
  15744. if (isObject(options)) {
  15745. var separator = 'separator' in options ? options.separator : separator;
  15746. length = 'length' in options ? toInteger(options.length) : length;
  15747. omission = 'omission' in options ? baseToString(options.omission) : omission;
  15748. }
  15749. string = toString(string);
  15750. var strLength = string.length;
  15751. if (hasUnicode(string)) {
  15752. var strSymbols = stringToArray(string);
  15753. strLength = strSymbols.length;
  15754. }
  15755. if (length >= strLength) {
  15756. return string;
  15757. }
  15758. var end = length - stringSize(omission);
  15759. if (end < 1) {
  15760. return omission;
  15761. }
  15762. var result = strSymbols
  15763. ? castSlice(strSymbols, 0, end).join('')
  15764. : string.slice(0, end);
  15765. if (separator === undefined) {
  15766. return result + omission;
  15767. }
  15768. if (strSymbols) {
  15769. end += (result.length - end);
  15770. }
  15771. if (isRegExp(separator)) {
  15772. if (string.slice(end).search(separator)) {
  15773. var match,
  15774. substring = result;
  15775. if (!separator.global) {
  15776. separator = RegExp(separator.source, toString(reFlags.exec(separator)) + 'g');
  15777. }
  15778. separator.lastIndex = 0;
  15779. while ((match = separator.exec(substring))) {
  15780. var newEnd = match.index;
  15781. }
  15782. result = result.slice(0, newEnd === undefined ? end : newEnd);
  15783. }
  15784. } else if (string.indexOf(baseToString(separator), end) != end) {
  15785. var index = result.lastIndexOf(separator);
  15786. if (index > -1) {
  15787. result = result.slice(0, index);
  15788. }
  15789. }
  15790. return result + omission;
  15791. }
  15792. /**
  15793. * The inverse of `_.escape`; this method converts the HTML entities
  15794. * `&amp;`, `&lt;`, `&gt;`, `&quot;`, and `&#39;` in `string` to
  15795. * their corresponding characters.
  15796. *
  15797. * **Note:** No other HTML entities are unescaped. To unescape additional
  15798. * HTML entities use a third-party library like [_he_](https://mths.be/he).
  15799. *
  15800. * @static
  15801. * @memberOf _
  15802. * @since 0.6.0
  15803. * @category String
  15804. * @param {string} [string=''] The string to unescape.
  15805. * @returns {string} Returns the unescaped string.
  15806. * @example
  15807. *
  15808. * _.unescape('fred, barney, &amp; pebbles');
  15809. * // => 'fred, barney, & pebbles'
  15810. */
  15811. function unescape(string) {
  15812. string = toString(string);
  15813. return (string && reHasEscapedHtml.test(string))
  15814. ? string.replace(reEscapedHtml, unescapeHtmlChar)
  15815. : string;
  15816. }
  15817. /**
  15818. * Converts `string`, as space separated words, to upper case.
  15819. *
  15820. * @static
  15821. * @memberOf _
  15822. * @since 4.0.0
  15823. * @category String
  15824. * @param {string} [string=''] The string to convert.
  15825. * @returns {string} Returns the upper cased string.
  15826. * @example
  15827. *
  15828. * _.upperCase('--foo-bar');
  15829. * // => 'FOO BAR'
  15830. *
  15831. * _.upperCase('fooBar');
  15832. * // => 'FOO BAR'
  15833. *
  15834. * _.upperCase('__foo_bar__');
  15835. * // => 'FOO BAR'
  15836. */
  15837. var upperCase = createCompounder(function(result, word, index) {
  15838. return result + (index ? ' ' : '') + word.toUpperCase();
  15839. });
  15840. /**
  15841. * Converts the first character of `string` to upper case.
  15842. *
  15843. * @static
  15844. * @memberOf _
  15845. * @since 4.0.0
  15846. * @category String
  15847. * @param {string} [string=''] The string to convert.
  15848. * @returns {string} Returns the converted string.
  15849. * @example
  15850. *
  15851. * _.upperFirst('fred');
  15852. * // => 'Fred'
  15853. *
  15854. * _.upperFirst('FRED');
  15855. * // => 'FRED'
  15856. */
  15857. var upperFirst = createCaseFirst('toUpperCase');
  15858. /**
  15859. * Splits `string` into an array of its words.
  15860. *
  15861. * @static
  15862. * @memberOf _
  15863. * @since 3.0.0
  15864. * @category String
  15865. * @param {string} [string=''] The string to inspect.
  15866. * @param {RegExp|string} [pattern] The pattern to match words.
  15867. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  15868. * @returns {Array} Returns the words of `string`.
  15869. * @example
  15870. *
  15871. * _.words('fred, barney, & pebbles');
  15872. * // => ['fred', 'barney', 'pebbles']
  15873. *
  15874. * _.words('fred, barney, & pebbles', /[^, ]+/g);
  15875. * // => ['fred', 'barney', '&', 'pebbles']
  15876. */
  15877. function words(string, pattern, guard) {
  15878. string = toString(string);
  15879. pattern = guard ? undefined : pattern;
  15880. if (pattern === undefined) {
  15881. return hasUnicodeWord(string) ? unicodeWords(string) : asciiWords(string);
  15882. }
  15883. return string.match(pattern) || [];
  15884. }
  15885. /*------------------------------------------------------------------------*/
  15886. /**
  15887. * Attempts to invoke `func`, returning either the result or the caught error
  15888. * object. Any additional arguments are provided to `func` when it's invoked.
  15889. *
  15890. * @static
  15891. * @memberOf _
  15892. * @since 3.0.0
  15893. * @category Util
  15894. * @param {Function} func The function to attempt.
  15895. * @param {...*} [args] The arguments to invoke `func` with.
  15896. * @returns {*} Returns the `func` result or error object.
  15897. * @example
  15898. *
  15899. * // Avoid throwing errors for invalid selectors.
  15900. * var elements = _.attempt(function(selector) {
  15901. * return document.querySelectorAll(selector);
  15902. * }, '>_>');
  15903. *
  15904. * if (_.isError(elements)) {
  15905. * elements = [];
  15906. * }
  15907. */
  15908. var attempt = baseRest(function(func, args) {
  15909. try {
  15910. return apply(func, undefined, args);
  15911. } catch (e) {
  15912. return isError(e) ? e : new Error(e);
  15913. }
  15914. });
  15915. /**
  15916. * Binds methods of an object to the object itself, overwriting the existing
  15917. * method.
  15918. *
  15919. * **Note:** This method doesn't set the "length" property of bound functions.
  15920. *
  15921. * @static
  15922. * @since 0.1.0
  15923. * @memberOf _
  15924. * @category Util
  15925. * @param {Object} object The object to bind and assign the bound methods to.
  15926. * @param {...(string|string[])} methodNames The object method names to bind.
  15927. * @returns {Object} Returns `object`.
  15928. * @example
  15929. *
  15930. * var view = {
  15931. * 'label': 'docs',
  15932. * 'click': function() {
  15933. * console.log('clicked ' + this.label);
  15934. * }
  15935. * };
  15936. *
  15937. * _.bindAll(view, ['click']);
  15938. * jQuery(element).on('click', view.click);
  15939. * // => Logs 'clicked docs' when clicked.
  15940. */
  15941. var bindAll = flatRest(function(object, methodNames) {
  15942. arrayEach(methodNames, function(key) {
  15943. key = toKey(key);
  15944. baseAssignValue(object, key, bind(object[key], object));
  15945. });
  15946. return object;
  15947. });
  15948. /**
  15949. * Creates a function that iterates over `pairs` and invokes the corresponding
  15950. * function of the first predicate to return truthy. The predicate-function
  15951. * pairs are invoked with the `this` binding and arguments of the created
  15952. * function.
  15953. *
  15954. * @static
  15955. * @memberOf _
  15956. * @since 4.0.0
  15957. * @category Util
  15958. * @param {Array} pairs The predicate-function pairs.
  15959. * @returns {Function} Returns the new composite function.
  15960. * @example
  15961. *
  15962. * var func = _.cond([
  15963. * [_.matches({ 'a': 1 }), _.constant('matches A')],
  15964. * [_.conforms({ 'b': _.isNumber }), _.constant('matches B')],
  15965. * [_.stubTrue, _.constant('no match')]
  15966. * ]);
  15967. *
  15968. * func({ 'a': 1, 'b': 2 });
  15969. * // => 'matches A'
  15970. *
  15971. * func({ 'a': 0, 'b': 1 });
  15972. * // => 'matches B'
  15973. *
  15974. * func({ 'a': '1', 'b': '2' });
  15975. * // => 'no match'
  15976. */
  15977. function cond(pairs) {
  15978. var length = pairs == null ? 0 : pairs.length,
  15979. toIteratee = getIteratee();
  15980. pairs = !length ? [] : arrayMap(pairs, function(pair) {
  15981. if (typeof pair[1] != 'function') {
  15982. throw new TypeError(FUNC_ERROR_TEXT);
  15983. }
  15984. return [toIteratee(pair[0]), pair[1]];
  15985. });
  15986. return baseRest(function(args) {
  15987. var index = -1;
  15988. while (++index < length) {
  15989. var pair = pairs[index];
  15990. if (apply(pair[0], this, args)) {
  15991. return apply(pair[1], this, args);
  15992. }
  15993. }
  15994. });
  15995. }
  15996. /**
  15997. * Creates a function that invokes the predicate properties of `source` with
  15998. * the corresponding property values of a given object, returning `true` if
  15999. * all predicates return truthy, else `false`.
  16000. *
  16001. * **Note:** The created function is equivalent to `_.conformsTo` with
  16002. * `source` partially applied.
  16003. *
  16004. * @static
  16005. * @memberOf _
  16006. * @since 4.0.0
  16007. * @category Util
  16008. * @param {Object} source The object of property predicates to conform to.
  16009. * @returns {Function} Returns the new spec function.
  16010. * @example
  16011. *
  16012. * var objects = [
  16013. * { 'a': 2, 'b': 1 },
  16014. * { 'a': 1, 'b': 2 }
  16015. * ];
  16016. *
  16017. * _.filter(objects, _.conforms({ 'b': function(n) { return n > 1; } }));
  16018. * // => [{ 'a': 1, 'b': 2 }]
  16019. */
  16020. function conforms(source) {
  16021. return baseConforms(baseClone(source, CLONE_DEEP_FLAG));
  16022. }
  16023. /**
  16024. * Creates a function that returns `value`.
  16025. *
  16026. * @static
  16027. * @memberOf _
  16028. * @since 2.4.0
  16029. * @category Util
  16030. * @param {*} value The value to return from the new function.
  16031. * @returns {Function} Returns the new constant function.
  16032. * @example
  16033. *
  16034. * var objects = _.times(2, _.constant({ 'a': 1 }));
  16035. *
  16036. * console.log(objects);
  16037. * // => [{ 'a': 1 }, { 'a': 1 }]
  16038. *
  16039. * console.log(objects[0] === objects[1]);
  16040. * // => true
  16041. */
  16042. function constant(value) {
  16043. return function() {
  16044. return value;
  16045. };
  16046. }
  16047. /**
  16048. * Checks `value` to determine whether a default value should be returned in
  16049. * its place. The `defaultValue` is returned if `value` is `NaN`, `null`,
  16050. * or `undefined`.
  16051. *
  16052. * @static
  16053. * @memberOf _
  16054. * @since 4.14.0
  16055. * @category Util
  16056. * @param {*} value The value to check.
  16057. * @param {*} defaultValue The default value.
  16058. * @returns {*} Returns the resolved value.
  16059. * @example
  16060. *
  16061. * _.defaultTo(1, 10);
  16062. * // => 1
  16063. *
  16064. * _.defaultTo(undefined, 10);
  16065. * // => 10
  16066. */
  16067. function defaultTo(value, defaultValue) {
  16068. return (value == null || value !== value) ? defaultValue : value;
  16069. }
  16070. /**
  16071. * Creates a function that returns the result of invoking the given functions
  16072. * with the `this` binding of the created function, where each successive
  16073. * invocation is supplied the return value of the previous.
  16074. *
  16075. * @static
  16076. * @memberOf _
  16077. * @since 3.0.0
  16078. * @category Util
  16079. * @param {...(Function|Function[])} [funcs] The functions to invoke.
  16080. * @returns {Function} Returns the new composite function.
  16081. * @see _.flowRight
  16082. * @example
  16083. *
  16084. * function square(n) {
  16085. * return n * n;
  16086. * }
  16087. *
  16088. * var addSquare = _.flow([_.add, square]);
  16089. * addSquare(1, 2);
  16090. * // => 9
  16091. */
  16092. var flow = createFlow();
  16093. /**
  16094. * This method is like `_.flow` except that it creates a function that
  16095. * invokes the given functions from right to left.
  16096. *
  16097. * @static
  16098. * @since 3.0.0
  16099. * @memberOf _
  16100. * @category Util
  16101. * @param {...(Function|Function[])} [funcs] The functions to invoke.
  16102. * @returns {Function} Returns the new composite function.
  16103. * @see _.flow
  16104. * @example
  16105. *
  16106. * function square(n) {
  16107. * return n * n;
  16108. * }
  16109. *
  16110. * var addSquare = _.flowRight([square, _.add]);
  16111. * addSquare(1, 2);
  16112. * // => 9
  16113. */
  16114. var flowRight = createFlow(true);
  16115. /**
  16116. * This method returns the first argument it receives.
  16117. *
  16118. * @static
  16119. * @since 0.1.0
  16120. * @memberOf _
  16121. * @category Util
  16122. * @param {*} value Any value.
  16123. * @returns {*} Returns `value`.
  16124. * @example
  16125. *
  16126. * var object = { 'a': 1 };
  16127. *
  16128. * console.log(_.identity(object) === object);
  16129. * // => true
  16130. */
  16131. function identity(value) {
  16132. return value;
  16133. }
  16134. /**
  16135. * Creates a function that invokes `func` with the arguments of the created
  16136. * function. If `func` is a property name, the created function returns the
  16137. * property value for a given element. If `func` is an array or object, the
  16138. * created function returns `true` for elements that contain the equivalent
  16139. * source properties, otherwise it returns `false`.
  16140. *
  16141. * @static
  16142. * @since 4.0.0
  16143. * @memberOf _
  16144. * @category Util
  16145. * @param {*} [func=_.identity] The value to convert to a callback.
  16146. * @returns {Function} Returns the callback.
  16147. * @example
  16148. *
  16149. * var users = [
  16150. * { 'user': 'barney', 'age': 36, 'active': true },
  16151. * { 'user': 'fred', 'age': 40, 'active': false }
  16152. * ];
  16153. *
  16154. * // The `_.matches` iteratee shorthand.
  16155. * _.filter(users, _.iteratee({ 'user': 'barney', 'active': true }));
  16156. * // => [{ 'user': 'barney', 'age': 36, 'active': true }]
  16157. *
  16158. * // The `_.matchesProperty` iteratee shorthand.
  16159. * _.filter(users, _.iteratee(['user', 'fred']));
  16160. * // => [{ 'user': 'fred', 'age': 40 }]
  16161. *
  16162. * // The `_.property` iteratee shorthand.
  16163. * _.map(users, _.iteratee('user'));
  16164. * // => ['barney', 'fred']
  16165. *
  16166. * // Create custom iteratee shorthands.
  16167. * _.iteratee = _.wrap(_.iteratee, function(iteratee, func) {
  16168. * return !_.isRegExp(func) ? iteratee(func) : function(string) {
  16169. * return func.test(string);
  16170. * };
  16171. * });
  16172. *
  16173. * _.filter(['abc', 'def'], /ef/);
  16174. * // => ['def']
  16175. */
  16176. function iteratee(func) {
  16177. return baseIteratee(typeof func == 'function' ? func : baseClone(func, CLONE_DEEP_FLAG));
  16178. }
  16179. /**
  16180. * Creates a function that performs a partial deep comparison between a given
  16181. * object and `source`, returning `true` if the given object has equivalent
  16182. * property values, else `false`.
  16183. *
  16184. * **Note:** The created function is equivalent to `_.isMatch` with `source`
  16185. * partially applied.
  16186. *
  16187. * Partial comparisons will match empty array and empty object `source`
  16188. * values against any array or object value, respectively. See `_.isEqual`
  16189. * for a list of supported value comparisons.
  16190. *
  16191. * **Note:** Multiple values can be checked by combining several matchers
  16192. * using `_.overSome`
  16193. *
  16194. * @static
  16195. * @memberOf _
  16196. * @since 3.0.0
  16197. * @category Util
  16198. * @param {Object} source The object of property values to match.
  16199. * @returns {Function} Returns the new spec function.
  16200. * @example
  16201. *
  16202. * var objects = [
  16203. * { 'a': 1, 'b': 2, 'c': 3 },
  16204. * { 'a': 4, 'b': 5, 'c': 6 }
  16205. * ];
  16206. *
  16207. * _.filter(objects, _.matches({ 'a': 4, 'c': 6 }));
  16208. * // => [{ 'a': 4, 'b': 5, 'c': 6 }]
  16209. *
  16210. * // Checking for several possible values
  16211. * _.filter(objects, _.overSome([_.matches({ 'a': 1 }), _.matches({ 'a': 4 })]));
  16212. * // => [{ 'a': 1, 'b': 2, 'c': 3 }, { 'a': 4, 'b': 5, 'c': 6 }]
  16213. */
  16214. function matches(source) {
  16215. return baseMatches(baseClone(source, CLONE_DEEP_FLAG));
  16216. }
  16217. /**
  16218. * Creates a function that performs a partial deep comparison between the
  16219. * value at `path` of a given object to `srcValue`, returning `true` if the
  16220. * object value is equivalent, else `false`.
  16221. *
  16222. * **Note:** Partial comparisons will match empty array and empty object
  16223. * `srcValue` values against any array or object value, respectively. See
  16224. * `_.isEqual` for a list of supported value comparisons.
  16225. *
  16226. * **Note:** Multiple values can be checked by combining several matchers
  16227. * using `_.overSome`
  16228. *
  16229. * @static
  16230. * @memberOf _
  16231. * @since 3.2.0
  16232. * @category Util
  16233. * @param {Array|string} path The path of the property to get.
  16234. * @param {*} srcValue The value to match.
  16235. * @returns {Function} Returns the new spec function.
  16236. * @example
  16237. *
  16238. * var objects = [
  16239. * { 'a': 1, 'b': 2, 'c': 3 },
  16240. * { 'a': 4, 'b': 5, 'c': 6 }
  16241. * ];
  16242. *
  16243. * _.find(objects, _.matchesProperty('a', 4));
  16244. * // => { 'a': 4, 'b': 5, 'c': 6 }
  16245. *
  16246. * // Checking for several possible values
  16247. * _.filter(objects, _.overSome([_.matchesProperty('a', 1), _.matchesProperty('a', 4)]));
  16248. * // => [{ 'a': 1, 'b': 2, 'c': 3 }, { 'a': 4, 'b': 5, 'c': 6 }]
  16249. */
  16250. function matchesProperty(path, srcValue) {
  16251. return baseMatchesProperty(path, baseClone(srcValue, CLONE_DEEP_FLAG));
  16252. }
  16253. /**
  16254. * Creates a function that invokes the method at `path` of a given object.
  16255. * Any additional arguments are provided to the invoked method.
  16256. *
  16257. * @static
  16258. * @memberOf _
  16259. * @since 3.7.0
  16260. * @category Util
  16261. * @param {Array|string} path The path of the method to invoke.
  16262. * @param {...*} [args] The arguments to invoke the method with.
  16263. * @returns {Function} Returns the new invoker function.
  16264. * @example
  16265. *
  16266. * var objects = [
  16267. * { 'a': { 'b': _.constant(2) } },
  16268. * { 'a': { 'b': _.constant(1) } }
  16269. * ];
  16270. *
  16271. * _.map(objects, _.method('a.b'));
  16272. * // => [2, 1]
  16273. *
  16274. * _.map(objects, _.method(['a', 'b']));
  16275. * // => [2, 1]
  16276. */
  16277. var method = baseRest(function(path, args) {
  16278. return function(object) {
  16279. return baseInvoke(object, path, args);
  16280. };
  16281. });
  16282. /**
  16283. * The opposite of `_.method`; this method creates a function that invokes
  16284. * the method at a given path of `object`. Any additional arguments are
  16285. * provided to the invoked method.
  16286. *
  16287. * @static
  16288. * @memberOf _
  16289. * @since 3.7.0
  16290. * @category Util
  16291. * @param {Object} object The object to query.
  16292. * @param {...*} [args] The arguments to invoke the method with.
  16293. * @returns {Function} Returns the new invoker function.
  16294. * @example
  16295. *
  16296. * var array = _.times(3, _.constant),
  16297. * object = { 'a': array, 'b': array, 'c': array };
  16298. *
  16299. * _.map(['a[2]', 'c[0]'], _.methodOf(object));
  16300. * // => [2, 0]
  16301. *
  16302. * _.map([['a', '2'], ['c', '0']], _.methodOf(object));
  16303. * // => [2, 0]
  16304. */
  16305. var methodOf = baseRest(function(object, args) {
  16306. return function(path) {
  16307. return baseInvoke(object, path, args);
  16308. };
  16309. });
  16310. /**
  16311. * Adds all own enumerable string keyed function properties of a source
  16312. * object to the destination object. If `object` is a function, then methods
  16313. * are added to its prototype as well.
  16314. *
  16315. * **Note:** Use `_.runInContext` to create a pristine `lodash` function to
  16316. * avoid conflicts caused by modifying the original.
  16317. *
  16318. * @static
  16319. * @since 0.1.0
  16320. * @memberOf _
  16321. * @category Util
  16322. * @param {Function|Object} [object=lodash] The destination object.
  16323. * @param {Object} source The object of functions to add.
  16324. * @param {Object} [options={}] The options object.
  16325. * @param {boolean} [options.chain=true] Specify whether mixins are chainable.
  16326. * @returns {Function|Object} Returns `object`.
  16327. * @example
  16328. *
  16329. * function vowels(string) {
  16330. * return _.filter(string, function(v) {
  16331. * return /[aeiou]/i.test(v);
  16332. * });
  16333. * }
  16334. *
  16335. * _.mixin({ 'vowels': vowels });
  16336. * _.vowels('fred');
  16337. * // => ['e']
  16338. *
  16339. * _('fred').vowels().value();
  16340. * // => ['e']
  16341. *
  16342. * _.mixin({ 'vowels': vowels }, { 'chain': false });
  16343. * _('fred').vowels();
  16344. * // => ['e']
  16345. */
  16346. function mixin(object, source, options) {
  16347. var props = keys(source),
  16348. methodNames = baseFunctions(source, props);
  16349. if (options == null &&
  16350. !(isObject(source) && (methodNames.length || !props.length))) {
  16351. options = source;
  16352. source = object;
  16353. object = this;
  16354. methodNames = baseFunctions(source, keys(source));
  16355. }
  16356. var chain = !(isObject(options) && 'chain' in options) || !!options.chain,
  16357. isFunc = isFunction(object);
  16358. arrayEach(methodNames, function(methodName) {
  16359. var func = source[methodName];
  16360. object[methodName] = func;
  16361. if (isFunc) {
  16362. object.prototype[methodName] = function() {
  16363. var chainAll = this.__chain__;
  16364. if (chain || chainAll) {
  16365. var result = object(this.__wrapped__),
  16366. actions = result.__actions__ = copyArray(this.__actions__);
  16367. actions.push({ 'func': func, 'args': arguments, 'thisArg': object });
  16368. result.__chain__ = chainAll;
  16369. return result;
  16370. }
  16371. return func.apply(object, arrayPush([this.value()], arguments));
  16372. };
  16373. }
  16374. });
  16375. return object;
  16376. }
  16377. /**
  16378. * Reverts the `_` variable to its previous value and returns a reference to
  16379. * the `lodash` function.
  16380. *
  16381. * @static
  16382. * @since 0.1.0
  16383. * @memberOf _
  16384. * @category Util
  16385. * @returns {Function} Returns the `lodash` function.
  16386. * @example
  16387. *
  16388. * var lodash = _.noConflict();
  16389. */
  16390. function noConflict() {
  16391. if (root._ === this) {
  16392. root._ = oldDash;
  16393. }
  16394. return this;
  16395. }
  16396. /**
  16397. * This method returns `undefined`.
  16398. *
  16399. * @static
  16400. * @memberOf _
  16401. * @since 2.3.0
  16402. * @category Util
  16403. * @example
  16404. *
  16405. * _.times(2, _.noop);
  16406. * // => [undefined, undefined]
  16407. */
  16408. function noop() {
  16409. // No operation performed.
  16410. }
  16411. /**
  16412. * Creates a function that gets the argument at index `n`. If `n` is negative,
  16413. * the nth argument from the end is returned.
  16414. *
  16415. * @static
  16416. * @memberOf _
  16417. * @since 4.0.0
  16418. * @category Util
  16419. * @param {number} [n=0] The index of the argument to return.
  16420. * @returns {Function} Returns the new pass-thru function.
  16421. * @example
  16422. *
  16423. * var func = _.nthArg(1);
  16424. * func('a', 'b', 'c', 'd');
  16425. * // => 'b'
  16426. *
  16427. * var func = _.nthArg(-2);
  16428. * func('a', 'b', 'c', 'd');
  16429. * // => 'c'
  16430. */
  16431. function nthArg(n) {
  16432. n = toInteger(n);
  16433. return baseRest(function(args) {
  16434. return baseNth(args, n);
  16435. });
  16436. }
  16437. /**
  16438. * Creates a function that invokes `iteratees` with the arguments it receives
  16439. * and returns their results.
  16440. *
  16441. * @static
  16442. * @memberOf _
  16443. * @since 4.0.0
  16444. * @category Util
  16445. * @param {...(Function|Function[])} [iteratees=[_.identity]]
  16446. * The iteratees to invoke.
  16447. * @returns {Function} Returns the new function.
  16448. * @example
  16449. *
  16450. * var func = _.over([Math.max, Math.min]);
  16451. *
  16452. * func(1, 2, 3, 4);
  16453. * // => [4, 1]
  16454. */
  16455. var over = createOver(arrayMap);
  16456. /**
  16457. * Creates a function that checks if **all** of the `predicates` return
  16458. * truthy when invoked with the arguments it receives.
  16459. *
  16460. * Following shorthands are possible for providing predicates.
  16461. * Pass an `Object` and it will be used as an parameter for `_.matches` to create the predicate.
  16462. * Pass an `Array` of parameters for `_.matchesProperty` and the predicate will be created using them.
  16463. *
  16464. * @static
  16465. * @memberOf _
  16466. * @since 4.0.0
  16467. * @category Util
  16468. * @param {...(Function|Function[])} [predicates=[_.identity]]
  16469. * The predicates to check.
  16470. * @returns {Function} Returns the new function.
  16471. * @example
  16472. *
  16473. * var func = _.overEvery([Boolean, isFinite]);
  16474. *
  16475. * func('1');
  16476. * // => true
  16477. *
  16478. * func(null);
  16479. * // => false
  16480. *
  16481. * func(NaN);
  16482. * // => false
  16483. */
  16484. var overEvery = createOver(arrayEvery);
  16485. /**
  16486. * Creates a function that checks if **any** of the `predicates` return
  16487. * truthy when invoked with the arguments it receives.
  16488. *
  16489. * Following shorthands are possible for providing predicates.
  16490. * Pass an `Object` and it will be used as an parameter for `_.matches` to create the predicate.
  16491. * Pass an `Array` of parameters for `_.matchesProperty` and the predicate will be created using them.
  16492. *
  16493. * @static
  16494. * @memberOf _
  16495. * @since 4.0.0
  16496. * @category Util
  16497. * @param {...(Function|Function[])} [predicates=[_.identity]]
  16498. * The predicates to check.
  16499. * @returns {Function} Returns the new function.
  16500. * @example
  16501. *
  16502. * var func = _.overSome([Boolean, isFinite]);
  16503. *
  16504. * func('1');
  16505. * // => true
  16506. *
  16507. * func(null);
  16508. * // => true
  16509. *
  16510. * func(NaN);
  16511. * // => false
  16512. *
  16513. * var matchesFunc = _.overSome([{ 'a': 1 }, { 'a': 2 }])
  16514. * var matchesPropertyFunc = _.overSome([['a', 1], ['a', 2]])
  16515. */
  16516. var overSome = createOver(arraySome);
  16517. /**
  16518. * Creates a function that returns the value at `path` of a given object.
  16519. *
  16520. * @static
  16521. * @memberOf _
  16522. * @since 2.4.0
  16523. * @category Util
  16524. * @param {Array|string} path The path of the property to get.
  16525. * @returns {Function} Returns the new accessor function.
  16526. * @example
  16527. *
  16528. * var objects = [
  16529. * { 'a': { 'b': 2 } },
  16530. * { 'a': { 'b': 1 } }
  16531. * ];
  16532. *
  16533. * _.map(objects, _.property('a.b'));
  16534. * // => [2, 1]
  16535. *
  16536. * _.map(_.sortBy(objects, _.property(['a', 'b'])), 'a.b');
  16537. * // => [1, 2]
  16538. */
  16539. function property(path) {
  16540. return isKey(path) ? baseProperty(toKey(path)) : basePropertyDeep(path);
  16541. }
  16542. /**
  16543. * The opposite of `_.property`; this method creates a function that returns
  16544. * the value at a given path of `object`.
  16545. *
  16546. * @static
  16547. * @memberOf _
  16548. * @since 3.0.0
  16549. * @category Util
  16550. * @param {Object} object The object to query.
  16551. * @returns {Function} Returns the new accessor function.
  16552. * @example
  16553. *
  16554. * var array = [0, 1, 2],
  16555. * object = { 'a': array, 'b': array, 'c': array };
  16556. *
  16557. * _.map(['a[2]', 'c[0]'], _.propertyOf(object));
  16558. * // => [2, 0]
  16559. *
  16560. * _.map([['a', '2'], ['c', '0']], _.propertyOf(object));
  16561. * // => [2, 0]
  16562. */
  16563. function propertyOf(object) {
  16564. return function(path) {
  16565. return object == null ? undefined : baseGet(object, path);
  16566. };
  16567. }
  16568. /**
  16569. * Creates an array of numbers (positive and/or negative) progressing from
  16570. * `start` up to, but not including, `end`. A step of `-1` is used if a negative
  16571. * `start` is specified without an `end` or `step`. If `end` is not specified,
  16572. * it's set to `start` with `start` then set to `0`.
  16573. *
  16574. * **Note:** JavaScript follows the IEEE-754 standard for resolving
  16575. * floating-point values which can produce unexpected results.
  16576. *
  16577. * @static
  16578. * @since 0.1.0
  16579. * @memberOf _
  16580. * @category Util
  16581. * @param {number} [start=0] The start of the range.
  16582. * @param {number} end The end of the range.
  16583. * @param {number} [step=1] The value to increment or decrement by.
  16584. * @returns {Array} Returns the range of numbers.
  16585. * @see _.inRange, _.rangeRight
  16586. * @example
  16587. *
  16588. * _.range(4);
  16589. * // => [0, 1, 2, 3]
  16590. *
  16591. * _.range(-4);
  16592. * // => [0, -1, -2, -3]
  16593. *
  16594. * _.range(1, 5);
  16595. * // => [1, 2, 3, 4]
  16596. *
  16597. * _.range(0, 20, 5);
  16598. * // => [0, 5, 10, 15]
  16599. *
  16600. * _.range(0, -4, -1);
  16601. * // => [0, -1, -2, -3]
  16602. *
  16603. * _.range(1, 4, 0);
  16604. * // => [1, 1, 1]
  16605. *
  16606. * _.range(0);
  16607. * // => []
  16608. */
  16609. var range = createRange();
  16610. /**
  16611. * This method is like `_.range` except that it populates values in
  16612. * descending order.
  16613. *
  16614. * @static
  16615. * @memberOf _
  16616. * @since 4.0.0
  16617. * @category Util
  16618. * @param {number} [start=0] The start of the range.
  16619. * @param {number} end The end of the range.
  16620. * @param {number} [step=1] The value to increment or decrement by.
  16621. * @returns {Array} Returns the range of numbers.
  16622. * @see _.inRange, _.range
  16623. * @example
  16624. *
  16625. * _.rangeRight(4);
  16626. * // => [3, 2, 1, 0]
  16627. *
  16628. * _.rangeRight(-4);
  16629. * // => [-3, -2, -1, 0]
  16630. *
  16631. * _.rangeRight(1, 5);
  16632. * // => [4, 3, 2, 1]
  16633. *
  16634. * _.rangeRight(0, 20, 5);
  16635. * // => [15, 10, 5, 0]
  16636. *
  16637. * _.rangeRight(0, -4, -1);
  16638. * // => [-3, -2, -1, 0]
  16639. *
  16640. * _.rangeRight(1, 4, 0);
  16641. * // => [1, 1, 1]
  16642. *
  16643. * _.rangeRight(0);
  16644. * // => []
  16645. */
  16646. var rangeRight = createRange(true);
  16647. /**
  16648. * This method returns a new empty array.
  16649. *
  16650. * @static
  16651. * @memberOf _
  16652. * @since 4.13.0
  16653. * @category Util
  16654. * @returns {Array} Returns the new empty array.
  16655. * @example
  16656. *
  16657. * var arrays = _.times(2, _.stubArray);
  16658. *
  16659. * console.log(arrays);
  16660. * // => [[], []]
  16661. *
  16662. * console.log(arrays[0] === arrays[1]);
  16663. * // => false
  16664. */
  16665. function stubArray() {
  16666. return [];
  16667. }
  16668. /**
  16669. * This method returns `false`.
  16670. *
  16671. * @static
  16672. * @memberOf _
  16673. * @since 4.13.0
  16674. * @category Util
  16675. * @returns {boolean} Returns `false`.
  16676. * @example
  16677. *
  16678. * _.times(2, _.stubFalse);
  16679. * // => [false, false]
  16680. */
  16681. function stubFalse() {
  16682. return false;
  16683. }
  16684. /**
  16685. * This method returns a new empty object.
  16686. *
  16687. * @static
  16688. * @memberOf _
  16689. * @since 4.13.0
  16690. * @category Util
  16691. * @returns {Object} Returns the new empty object.
  16692. * @example
  16693. *
  16694. * var objects = _.times(2, _.stubObject);
  16695. *
  16696. * console.log(objects);
  16697. * // => [{}, {}]
  16698. *
  16699. * console.log(objects[0] === objects[1]);
  16700. * // => false
  16701. */
  16702. function stubObject() {
  16703. return {};
  16704. }
  16705. /**
  16706. * This method returns an empty string.
  16707. *
  16708. * @static
  16709. * @memberOf _
  16710. * @since 4.13.0
  16711. * @category Util
  16712. * @returns {string} Returns the empty string.
  16713. * @example
  16714. *
  16715. * _.times(2, _.stubString);
  16716. * // => ['', '']
  16717. */
  16718. function stubString() {
  16719. return '';
  16720. }
  16721. /**
  16722. * This method returns `true`.
  16723. *
  16724. * @static
  16725. * @memberOf _
  16726. * @since 4.13.0
  16727. * @category Util
  16728. * @returns {boolean} Returns `true`.
  16729. * @example
  16730. *
  16731. * _.times(2, _.stubTrue);
  16732. * // => [true, true]
  16733. */
  16734. function stubTrue() {
  16735. return true;
  16736. }
  16737. /**
  16738. * Invokes the iteratee `n` times, returning an array of the results of
  16739. * each invocation. The iteratee is invoked with one argument; (index).
  16740. *
  16741. * @static
  16742. * @since 0.1.0
  16743. * @memberOf _
  16744. * @category Util
  16745. * @param {number} n The number of times to invoke `iteratee`.
  16746. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  16747. * @returns {Array} Returns the array of results.
  16748. * @example
  16749. *
  16750. * _.times(3, String);
  16751. * // => ['0', '1', '2']
  16752. *
  16753. * _.times(4, _.constant(0));
  16754. * // => [0, 0, 0, 0]
  16755. */
  16756. function times(n, iteratee) {
  16757. n = toInteger(n);
  16758. if (n < 1 || n > MAX_SAFE_INTEGER) {
  16759. return [];
  16760. }
  16761. var index = MAX_ARRAY_LENGTH,
  16762. length = nativeMin(n, MAX_ARRAY_LENGTH);
  16763. iteratee = getIteratee(iteratee);
  16764. n -= MAX_ARRAY_LENGTH;
  16765. var result = baseTimes(length, iteratee);
  16766. while (++index < n) {
  16767. iteratee(index);
  16768. }
  16769. return result;
  16770. }
  16771. /**
  16772. * Converts `value` to a property path array.
  16773. *
  16774. * @static
  16775. * @memberOf _
  16776. * @since 4.0.0
  16777. * @category Util
  16778. * @param {*} value The value to convert.
  16779. * @returns {Array} Returns the new property path array.
  16780. * @example
  16781. *
  16782. * _.toPath('a.b.c');
  16783. * // => ['a', 'b', 'c']
  16784. *
  16785. * _.toPath('a[0].b.c');
  16786. * // => ['a', '0', 'b', 'c']
  16787. */
  16788. function toPath(value) {
  16789. if (isArray(value)) {
  16790. return arrayMap(value, toKey);
  16791. }
  16792. return isSymbol(value) ? [value] : copyArray(stringToPath(toString(value)));
  16793. }
  16794. /**
  16795. * Generates a unique ID. If `prefix` is given, the ID is appended to it.
  16796. *
  16797. * @static
  16798. * @since 0.1.0
  16799. * @memberOf _
  16800. * @category Util
  16801. * @param {string} [prefix=''] The value to prefix the ID with.
  16802. * @returns {string} Returns the unique ID.
  16803. * @example
  16804. *
  16805. * _.uniqueId('contact_');
  16806. * // => 'contact_104'
  16807. *
  16808. * _.uniqueId();
  16809. * // => '105'
  16810. */
  16811. function uniqueId(prefix) {
  16812. var id = ++idCounter;
  16813. return toString(prefix) + id;
  16814. }
  16815. /*------------------------------------------------------------------------*/
  16816. /**
  16817. * Adds two numbers.
  16818. *
  16819. * @static
  16820. * @memberOf _
  16821. * @since 3.4.0
  16822. * @category Math
  16823. * @param {number} augend The first number in an addition.
  16824. * @param {number} addend The second number in an addition.
  16825. * @returns {number} Returns the total.
  16826. * @example
  16827. *
  16828. * _.add(6, 4);
  16829. * // => 10
  16830. */
  16831. var add = createMathOperation(function(augend, addend) {
  16832. return augend + addend;
  16833. }, 0);
  16834. /**
  16835. * Computes `number` rounded up to `precision`.
  16836. *
  16837. * @static
  16838. * @memberOf _
  16839. * @since 3.10.0
  16840. * @category Math
  16841. * @param {number} number The number to round up.
  16842. * @param {number} [precision=0] The precision to round up to.
  16843. * @returns {number} Returns the rounded up number.
  16844. * @example
  16845. *
  16846. * _.ceil(4.006);
  16847. * // => 5
  16848. *
  16849. * _.ceil(6.004, 2);
  16850. * // => 6.01
  16851. *
  16852. * _.ceil(6040, -2);
  16853. * // => 6100
  16854. */
  16855. var ceil = createRound('ceil');
  16856. /**
  16857. * Divide two numbers.
  16858. *
  16859. * @static
  16860. * @memberOf _
  16861. * @since 4.7.0
  16862. * @category Math
  16863. * @param {number} dividend The first number in a division.
  16864. * @param {number} divisor The second number in a division.
  16865. * @returns {number} Returns the quotient.
  16866. * @example
  16867. *
  16868. * _.divide(6, 4);
  16869. * // => 1.5
  16870. */
  16871. var divide = createMathOperation(function(dividend, divisor) {
  16872. return dividend / divisor;
  16873. }, 1);
  16874. /**
  16875. * Computes `number` rounded down to `precision`.
  16876. *
  16877. * @static
  16878. * @memberOf _
  16879. * @since 3.10.0
  16880. * @category Math
  16881. * @param {number} number The number to round down.
  16882. * @param {number} [precision=0] The precision to round down to.
  16883. * @returns {number} Returns the rounded down number.
  16884. * @example
  16885. *
  16886. * _.floor(4.006);
  16887. * // => 4
  16888. *
  16889. * _.floor(0.046, 2);
  16890. * // => 0.04
  16891. *
  16892. * _.floor(4060, -2);
  16893. * // => 4000
  16894. */
  16895. var floor = createRound('floor');
  16896. /**
  16897. * Computes the maximum value of `array`. If `array` is empty or falsey,
  16898. * `undefined` is returned.
  16899. *
  16900. * @static
  16901. * @since 0.1.0
  16902. * @memberOf _
  16903. * @category Math
  16904. * @param {Array} array The array to iterate over.
  16905. * @returns {*} Returns the maximum value.
  16906. * @example
  16907. *
  16908. * _.max([4, 2, 8, 6]);
  16909. * // => 8
  16910. *
  16911. * _.max([]);
  16912. * // => undefined
  16913. */
  16914. function max(array) {
  16915. return (array && array.length)
  16916. ? baseExtremum(array, identity, baseGt)
  16917. : undefined;
  16918. }
  16919. /**
  16920. * This method is like `_.max` except that it accepts `iteratee` which is
  16921. * invoked for each element in `array` to generate the criterion by which
  16922. * the value is ranked. The iteratee is invoked with one argument: (value).
  16923. *
  16924. * @static
  16925. * @memberOf _
  16926. * @since 4.0.0
  16927. * @category Math
  16928. * @param {Array} array The array to iterate over.
  16929. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  16930. * @returns {*} Returns the maximum value.
  16931. * @example
  16932. *
  16933. * var objects = [{ 'n': 1 }, { 'n': 2 }];
  16934. *
  16935. * _.maxBy(objects, function(o) { return o.n; });
  16936. * // => { 'n': 2 }
  16937. *
  16938. * // The `_.property` iteratee shorthand.
  16939. * _.maxBy(objects, 'n');
  16940. * // => { 'n': 2 }
  16941. */
  16942. function maxBy(array, iteratee) {
  16943. return (array && array.length)
  16944. ? baseExtremum(array, getIteratee(iteratee, 2), baseGt)
  16945. : undefined;
  16946. }
  16947. /**
  16948. * Computes the mean of the values in `array`.
  16949. *
  16950. * @static
  16951. * @memberOf _
  16952. * @since 4.0.0
  16953. * @category Math
  16954. * @param {Array} array The array to iterate over.
  16955. * @returns {number} Returns the mean.
  16956. * @example
  16957. *
  16958. * _.mean([4, 2, 8, 6]);
  16959. * // => 5
  16960. */
  16961. function mean(array) {
  16962. return baseMean(array, identity);
  16963. }
  16964. /**
  16965. * This method is like `_.mean` except that it accepts `iteratee` which is
  16966. * invoked for each element in `array` to generate the value to be averaged.
  16967. * The iteratee is invoked with one argument: (value).
  16968. *
  16969. * @static
  16970. * @memberOf _
  16971. * @since 4.7.0
  16972. * @category Math
  16973. * @param {Array} array The array to iterate over.
  16974. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  16975. * @returns {number} Returns the mean.
  16976. * @example
  16977. *
  16978. * var objects = [{ 'n': 4 }, { 'n': 2 }, { 'n': 8 }, { 'n': 6 }];
  16979. *
  16980. * _.meanBy(objects, function(o) { return o.n; });
  16981. * // => 5
  16982. *
  16983. * // The `_.property` iteratee shorthand.
  16984. * _.meanBy(objects, 'n');
  16985. * // => 5
  16986. */
  16987. function meanBy(array, iteratee) {
  16988. return baseMean(array, getIteratee(iteratee, 2));
  16989. }
  16990. /**
  16991. * Computes the minimum value of `array`. If `array` is empty or falsey,
  16992. * `undefined` is returned.
  16993. *
  16994. * @static
  16995. * @since 0.1.0
  16996. * @memberOf _
  16997. * @category Math
  16998. * @param {Array} array The array to iterate over.
  16999. * @returns {*} Returns the minimum value.
  17000. * @example
  17001. *
  17002. * _.min([4, 2, 8, 6]);
  17003. * // => 2
  17004. *
  17005. * _.min([]);
  17006. * // => undefined
  17007. */
  17008. function min(array) {
  17009. return (array && array.length)
  17010. ? baseExtremum(array, identity, baseLt)
  17011. : undefined;
  17012. }
  17013. /**
  17014. * This method is like `_.min` except that it accepts `iteratee` which is
  17015. * invoked for each element in `array` to generate the criterion by which
  17016. * the value is ranked. The iteratee is invoked with one argument: (value).
  17017. *
  17018. * @static
  17019. * @memberOf _
  17020. * @since 4.0.0
  17021. * @category Math
  17022. * @param {Array} array The array to iterate over.
  17023. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  17024. * @returns {*} Returns the minimum value.
  17025. * @example
  17026. *
  17027. * var objects = [{ 'n': 1 }, { 'n': 2 }];
  17028. *
  17029. * _.minBy(objects, function(o) { return o.n; });
  17030. * // => { 'n': 1 }
  17031. *
  17032. * // The `_.property` iteratee shorthand.
  17033. * _.minBy(objects, 'n');
  17034. * // => { 'n': 1 }
  17035. */
  17036. function minBy(array, iteratee) {
  17037. return (array && array.length)
  17038. ? baseExtremum(array, getIteratee(iteratee, 2), baseLt)
  17039. : undefined;
  17040. }
  17041. /**
  17042. * Multiply two numbers.
  17043. *
  17044. * @static
  17045. * @memberOf _
  17046. * @since 4.7.0
  17047. * @category Math
  17048. * @param {number} multiplier The first number in a multiplication.
  17049. * @param {number} multiplicand The second number in a multiplication.
  17050. * @returns {number} Returns the product.
  17051. * @example
  17052. *
  17053. * _.multiply(6, 4);
  17054. * // => 24
  17055. */
  17056. var multiply = createMathOperation(function(multiplier, multiplicand) {
  17057. return multiplier * multiplicand;
  17058. }, 1);
  17059. /**
  17060. * Computes `number` rounded to `precision`.
  17061. *
  17062. * @static
  17063. * @memberOf _
  17064. * @since 3.10.0
  17065. * @category Math
  17066. * @param {number} number The number to round.
  17067. * @param {number} [precision=0] The precision to round to.
  17068. * @returns {number} Returns the rounded number.
  17069. * @example
  17070. *
  17071. * _.round(4.006);
  17072. * // => 4
  17073. *
  17074. * _.round(4.006, 2);
  17075. * // => 4.01
  17076. *
  17077. * _.round(4060, -2);
  17078. * // => 4100
  17079. */
  17080. var round = createRound('round');
  17081. /**
  17082. * Subtract two numbers.
  17083. *
  17084. * @static
  17085. * @memberOf _
  17086. * @since 4.0.0
  17087. * @category Math
  17088. * @param {number} minuend The first number in a subtraction.
  17089. * @param {number} subtrahend The second number in a subtraction.
  17090. * @returns {number} Returns the difference.
  17091. * @example
  17092. *
  17093. * _.subtract(6, 4);
  17094. * // => 2
  17095. */
  17096. var subtract = createMathOperation(function(minuend, subtrahend) {
  17097. return minuend - subtrahend;
  17098. }, 0);
  17099. /**
  17100. * Computes the sum of the values in `array`.
  17101. *
  17102. * @static
  17103. * @memberOf _
  17104. * @since 3.4.0
  17105. * @category Math
  17106. * @param {Array} array The array to iterate over.
  17107. * @returns {number} Returns the sum.
  17108. * @example
  17109. *
  17110. * _.sum([4, 2, 8, 6]);
  17111. * // => 20
  17112. */
  17113. function sum(array) {
  17114. return (array && array.length)
  17115. ? baseSum(array, identity)
  17116. : 0;
  17117. }
  17118. /**
  17119. * This method is like `_.sum` except that it accepts `iteratee` which is
  17120. * invoked for each element in `array` to generate the value to be summed.
  17121. * The iteratee is invoked with one argument: (value).
  17122. *
  17123. * @static
  17124. * @memberOf _
  17125. * @since 4.0.0
  17126. * @category Math
  17127. * @param {Array} array The array to iterate over.
  17128. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  17129. * @returns {number} Returns the sum.
  17130. * @example
  17131. *
  17132. * var objects = [{ 'n': 4 }, { 'n': 2 }, { 'n': 8 }, { 'n': 6 }];
  17133. *
  17134. * _.sumBy(objects, function(o) { return o.n; });
  17135. * // => 20
  17136. *
  17137. * // The `_.property` iteratee shorthand.
  17138. * _.sumBy(objects, 'n');
  17139. * // => 20
  17140. */
  17141. function sumBy(array, iteratee) {
  17142. return (array && array.length)
  17143. ? baseSum(array, getIteratee(iteratee, 2))
  17144. : 0;
  17145. }
  17146. /*------------------------------------------------------------------------*/
  17147. // Add methods that return wrapped values in chain sequences.
  17148. lodash.after = after;
  17149. lodash.ary = ary;
  17150. lodash.assign = assign;
  17151. lodash.assignIn = assignIn;
  17152. lodash.assignInWith = assignInWith;
  17153. lodash.assignWith = assignWith;
  17154. lodash.at = at;
  17155. lodash.before = before;
  17156. lodash.bind = bind;
  17157. lodash.bindAll = bindAll;
  17158. lodash.bindKey = bindKey;
  17159. lodash.castArray = castArray;
  17160. lodash.chain = chain;
  17161. lodash.chunk = chunk;
  17162. lodash.compact = compact;
  17163. lodash.concat = concat;
  17164. lodash.cond = cond;
  17165. lodash.conforms = conforms;
  17166. lodash.constant = constant;
  17167. lodash.countBy = countBy;
  17168. lodash.create = create;
  17169. lodash.curry = curry;
  17170. lodash.curryRight = curryRight;
  17171. lodash.debounce = debounce;
  17172. lodash.defaults = defaults;
  17173. lodash.defaultsDeep = defaultsDeep;
  17174. lodash.defer = defer;
  17175. lodash.delay = delay;
  17176. lodash.difference = difference;
  17177. lodash.differenceBy = differenceBy;
  17178. lodash.differenceWith = differenceWith;
  17179. lodash.drop = drop;
  17180. lodash.dropRight = dropRight;
  17181. lodash.dropRightWhile = dropRightWhile;
  17182. lodash.dropWhile = dropWhile;
  17183. lodash.fill = fill;
  17184. lodash.filter = filter;
  17185. lodash.flatMap = flatMap;
  17186. lodash.flatMapDeep = flatMapDeep;
  17187. lodash.flatMapDepth = flatMapDepth;
  17188. lodash.flatten = flatten;
  17189. lodash.flattenDeep = flattenDeep;
  17190. lodash.flattenDepth = flattenDepth;
  17191. lodash.flip = flip;
  17192. lodash.flow = flow;
  17193. lodash.flowRight = flowRight;
  17194. lodash.fromPairs = fromPairs;
  17195. lodash.functions = functions;
  17196. lodash.functionsIn = functionsIn;
  17197. lodash.groupBy = groupBy;
  17198. lodash.initial = initial;
  17199. lodash.intersection = intersection;
  17200. lodash.intersectionBy = intersectionBy;
  17201. lodash.intersectionWith = intersectionWith;
  17202. lodash.invert = invert;
  17203. lodash.invertBy = invertBy;
  17204. lodash.invokeMap = invokeMap;
  17205. lodash.iteratee = iteratee;
  17206. lodash.keyBy = keyBy;
  17207. lodash.keys = keys;
  17208. lodash.keysIn = keysIn;
  17209. lodash.map = map;
  17210. lodash.mapKeys = mapKeys;
  17211. lodash.mapValues = mapValues;
  17212. lodash.matches = matches;
  17213. lodash.matchesProperty = matchesProperty;
  17214. lodash.memoize = memoize;
  17215. lodash.merge = merge;
  17216. lodash.mergeWith = mergeWith;
  17217. lodash.method = method;
  17218. lodash.methodOf = methodOf;
  17219. lodash.mixin = mixin;
  17220. lodash.negate = negate;
  17221. lodash.nthArg = nthArg;
  17222. lodash.omit = omit;
  17223. lodash.omitBy = omitBy;
  17224. lodash.once = once;
  17225. lodash.orderBy = orderBy;
  17226. lodash.over = over;
  17227. lodash.overArgs = overArgs;
  17228. lodash.overEvery = overEvery;
  17229. lodash.overSome = overSome;
  17230. lodash.partial = partial;
  17231. lodash.partialRight = partialRight;
  17232. lodash.partition = partition;
  17233. lodash.pick = pick;
  17234. lodash.pickBy = pickBy;
  17235. lodash.property = property;
  17236. lodash.propertyOf = propertyOf;
  17237. lodash.pull = pull;
  17238. lodash.pullAll = pullAll;
  17239. lodash.pullAllBy = pullAllBy;
  17240. lodash.pullAllWith = pullAllWith;
  17241. lodash.pullAt = pullAt;
  17242. lodash.range = range;
  17243. lodash.rangeRight = rangeRight;
  17244. lodash.rearg = rearg;
  17245. lodash.reject = reject;
  17246. lodash.remove = remove;
  17247. lodash.rest = rest;
  17248. lodash.reverse = reverse;
  17249. lodash.sampleSize = sampleSize;
  17250. lodash.set = set;
  17251. lodash.setWith = setWith;
  17252. lodash.shuffle = shuffle;
  17253. lodash.slice = slice;
  17254. lodash.sortBy = sortBy;
  17255. lodash.sortedUniq = sortedUniq;
  17256. lodash.sortedUniqBy = sortedUniqBy;
  17257. lodash.split = split;
  17258. lodash.spread = spread;
  17259. lodash.tail = tail;
  17260. lodash.take = take;
  17261. lodash.takeRight = takeRight;
  17262. lodash.takeRightWhile = takeRightWhile;
  17263. lodash.takeWhile = takeWhile;
  17264. lodash.tap = tap;
  17265. lodash.throttle = throttle;
  17266. lodash.thru = thru;
  17267. lodash.toArray = toArray;
  17268. lodash.toPairs = toPairs;
  17269. lodash.toPairsIn = toPairsIn;
  17270. lodash.toPath = toPath;
  17271. lodash.toPlainObject = toPlainObject;
  17272. lodash.transform = transform;
  17273. lodash.unary = unary;
  17274. lodash.union = union;
  17275. lodash.unionBy = unionBy;
  17276. lodash.unionWith = unionWith;
  17277. lodash.uniq = uniq;
  17278. lodash.uniqBy = uniqBy;
  17279. lodash.uniqWith = uniqWith;
  17280. lodash.unset = unset;
  17281. lodash.unzip = unzip;
  17282. lodash.unzipWith = unzipWith;
  17283. lodash.update = update;
  17284. lodash.updateWith = updateWith;
  17285. lodash.values = values;
  17286. lodash.valuesIn = valuesIn;
  17287. lodash.without = without;
  17288. lodash.words = words;
  17289. lodash.wrap = wrap;
  17290. lodash.xor = xor;
  17291. lodash.xorBy = xorBy;
  17292. lodash.xorWith = xorWith;
  17293. lodash.zip = zip;
  17294. lodash.zipObject = zipObject;
  17295. lodash.zipObjectDeep = zipObjectDeep;
  17296. lodash.zipWith = zipWith;
  17297. // Add aliases.
  17298. lodash.entries = toPairs;
  17299. lodash.entriesIn = toPairsIn;
  17300. lodash.extend = assignIn;
  17301. lodash.extendWith = assignInWith;
  17302. // Add methods to `lodash.prototype`.
  17303. mixin(lodash, lodash);
  17304. /*------------------------------------------------------------------------*/
  17305. // Add methods that return unwrapped values in chain sequences.
  17306. lodash.add = add;
  17307. lodash.attempt = attempt;
  17308. lodash.camelCase = camelCase;
  17309. lodash.capitalize = capitalize;
  17310. lodash.ceil = ceil;
  17311. lodash.clamp = clamp;
  17312. lodash.clone = clone;
  17313. lodash.cloneDeep = cloneDeep;
  17314. lodash.cloneDeepWith = cloneDeepWith;
  17315. lodash.cloneWith = cloneWith;
  17316. lodash.conformsTo = conformsTo;
  17317. lodash.deburr = deburr;
  17318. lodash.defaultTo = defaultTo;
  17319. lodash.divide = divide;
  17320. lodash.endsWith = endsWith;
  17321. lodash.eq = eq;
  17322. lodash.escape = escape;
  17323. lodash.escapeRegExp = escapeRegExp;
  17324. lodash.every = every;
  17325. lodash.find = find;
  17326. lodash.findIndex = findIndex;
  17327. lodash.findKey = findKey;
  17328. lodash.findLast = findLast;
  17329. lodash.findLastIndex = findLastIndex;
  17330. lodash.findLastKey = findLastKey;
  17331. lodash.floor = floor;
  17332. lodash.forEach = forEach;
  17333. lodash.forEachRight = forEachRight;
  17334. lodash.forIn = forIn;
  17335. lodash.forInRight = forInRight;
  17336. lodash.forOwn = forOwn;
  17337. lodash.forOwnRight = forOwnRight;
  17338. lodash.get = get;
  17339. lodash.gt = gt;
  17340. lodash.gte = gte;
  17341. lodash.has = has;
  17342. lodash.hasIn = hasIn;
  17343. lodash.head = head;
  17344. lodash.identity = identity;
  17345. lodash.includes = includes;
  17346. lodash.indexOf = indexOf;
  17347. lodash.inRange = inRange;
  17348. lodash.invoke = invoke;
  17349. lodash.isArguments = isArguments;
  17350. lodash.isArray = isArray;
  17351. lodash.isArrayBuffer = isArrayBuffer;
  17352. lodash.isArrayLike = isArrayLike;
  17353. lodash.isArrayLikeObject = isArrayLikeObject;
  17354. lodash.isBoolean = isBoolean;
  17355. lodash.isBuffer = isBuffer;
  17356. lodash.isDate = isDate;
  17357. lodash.isElement = isElement;
  17358. lodash.isEmpty = isEmpty;
  17359. lodash.isEqual = isEqual;
  17360. lodash.isEqualWith = isEqualWith;
  17361. lodash.isError = isError;
  17362. lodash.isFinite = isFinite;
  17363. lodash.isFunction = isFunction;
  17364. lodash.isInteger = isInteger;
  17365. lodash.isLength = isLength;
  17366. lodash.isMap = isMap;
  17367. lodash.isMatch = isMatch;
  17368. lodash.isMatchWith = isMatchWith;
  17369. lodash.isNaN = isNaN;
  17370. lodash.isNative = isNative;
  17371. lodash.isNil = isNil;
  17372. lodash.isNull = isNull;
  17373. lodash.isNumber = isNumber;
  17374. lodash.isObject = isObject;
  17375. lodash.isObjectLike = isObjectLike;
  17376. lodash.isPlainObject = isPlainObject;
  17377. lodash.isRegExp = isRegExp;
  17378. lodash.isSafeInteger = isSafeInteger;
  17379. lodash.isSet = isSet;
  17380. lodash.isString = isString;
  17381. lodash.isSymbol = isSymbol;
  17382. lodash.isTypedArray = isTypedArray;
  17383. lodash.isUndefined = isUndefined;
  17384. lodash.isWeakMap = isWeakMap;
  17385. lodash.isWeakSet = isWeakSet;
  17386. lodash.join = join;
  17387. lodash.kebabCase = kebabCase;
  17388. lodash.last = last;
  17389. lodash.lastIndexOf = lastIndexOf;
  17390. lodash.lowerCase = lowerCase;
  17391. lodash.lowerFirst = lowerFirst;
  17392. lodash.lt = lt;
  17393. lodash.lte = lte;
  17394. lodash.max = max;
  17395. lodash.maxBy = maxBy;
  17396. lodash.mean = mean;
  17397. lodash.meanBy = meanBy;
  17398. lodash.min = min;
  17399. lodash.minBy = minBy;
  17400. lodash.stubArray = stubArray;
  17401. lodash.stubFalse = stubFalse;
  17402. lodash.stubObject = stubObject;
  17403. lodash.stubString = stubString;
  17404. lodash.stubTrue = stubTrue;
  17405. lodash.multiply = multiply;
  17406. lodash.nth = nth;
  17407. lodash.noConflict = noConflict;
  17408. lodash.noop = noop;
  17409. lodash.now = now;
  17410. lodash.pad = pad;
  17411. lodash.padEnd = padEnd;
  17412. lodash.padStart = padStart;
  17413. lodash.parseInt = parseInt;
  17414. lodash.random = random;
  17415. lodash.reduce = reduce;
  17416. lodash.reduceRight = reduceRight;
  17417. lodash.repeat = repeat;
  17418. lodash.replace = replace;
  17419. lodash.result = result;
  17420. lodash.round = round;
  17421. lodash.runInContext = runInContext;
  17422. lodash.sample = sample;
  17423. lodash.size = size;
  17424. lodash.snakeCase = snakeCase;
  17425. lodash.some = some;
  17426. lodash.sortedIndex = sortedIndex;
  17427. lodash.sortedIndexBy = sortedIndexBy;
  17428. lodash.sortedIndexOf = sortedIndexOf;
  17429. lodash.sortedLastIndex = sortedLastIndex;
  17430. lodash.sortedLastIndexBy = sortedLastIndexBy;
  17431. lodash.sortedLastIndexOf = sortedLastIndexOf;
  17432. lodash.startCase = startCase;
  17433. lodash.startsWith = startsWith;
  17434. lodash.subtract = subtract;
  17435. lodash.sum = sum;
  17436. lodash.sumBy = sumBy;
  17437. lodash.template = template;
  17438. lodash.times = times;
  17439. lodash.toFinite = toFinite;
  17440. lodash.toInteger = toInteger;
  17441. lodash.toLength = toLength;
  17442. lodash.toLower = toLower;
  17443. lodash.toNumber = toNumber;
  17444. lodash.toSafeInteger = toSafeInteger;
  17445. lodash.toString = toString;
  17446. lodash.toUpper = toUpper;
  17447. lodash.trim = trim;
  17448. lodash.trimEnd = trimEnd;
  17449. lodash.trimStart = trimStart;
  17450. lodash.truncate = truncate;
  17451. lodash.unescape = unescape;
  17452. lodash.uniqueId = uniqueId;
  17453. lodash.upperCase = upperCase;
  17454. lodash.upperFirst = upperFirst;
  17455. // Add aliases.
  17456. lodash.each = forEach;
  17457. lodash.eachRight = forEachRight;
  17458. lodash.first = head;
  17459. mixin(lodash, (function() {
  17460. var source = {};
  17461. baseForOwn(lodash, function(func, methodName) {
  17462. if (!hasOwnProperty.call(lodash.prototype, methodName)) {
  17463. source[methodName] = func;
  17464. }
  17465. });
  17466. return source;
  17467. }()), { 'chain': false });
  17468. /*------------------------------------------------------------------------*/
  17469. /**
  17470. * The semantic version number.
  17471. *
  17472. * @static
  17473. * @memberOf _
  17474. * @type {string}
  17475. */
  17476. lodash.VERSION = VERSION;
  17477. // Assign default placeholders.
  17478. arrayEach(['bind', 'bindKey', 'curry', 'curryRight', 'partial', 'partialRight'], function(methodName) {
  17479. lodash[methodName].placeholder = lodash;
  17480. });
  17481. // Add `LazyWrapper` methods for `_.drop` and `_.take` variants.
  17482. arrayEach(['drop', 'take'], function(methodName, index) {
  17483. LazyWrapper.prototype[methodName] = function(n) {
  17484. n = n === undefined ? 1 : nativeMax(toInteger(n), 0);
  17485. var result = (this.__filtered__ && !index)
  17486. ? new LazyWrapper(this)
  17487. : this.clone();
  17488. if (result.__filtered__) {
  17489. result.__takeCount__ = nativeMin(n, result.__takeCount__);
  17490. } else {
  17491. result.__views__.push({
  17492. 'size': nativeMin(n, MAX_ARRAY_LENGTH),
  17493. 'type': methodName + (result.__dir__ < 0 ? 'Right' : '')
  17494. });
  17495. }
  17496. return result;
  17497. };
  17498. LazyWrapper.prototype[methodName + 'Right'] = function(n) {
  17499. return this.reverse()[methodName](n).reverse();
  17500. };
  17501. });
  17502. // Add `LazyWrapper` methods that accept an `iteratee` value.
  17503. arrayEach(['filter', 'map', 'takeWhile'], function(methodName, index) {
  17504. var type = index + 1,
  17505. isFilter = type == LAZY_FILTER_FLAG || type == LAZY_WHILE_FLAG;
  17506. LazyWrapper.prototype[methodName] = function(iteratee) {
  17507. var result = this.clone();
  17508. result.__iteratees__.push({
  17509. 'iteratee': getIteratee(iteratee, 3),
  17510. 'type': type
  17511. });
  17512. result.__filtered__ = result.__filtered__ || isFilter;
  17513. return result;
  17514. };
  17515. });
  17516. // Add `LazyWrapper` methods for `_.head` and `_.last`.
  17517. arrayEach(['head', 'last'], function(methodName, index) {
  17518. var takeName = 'take' + (index ? 'Right' : '');
  17519. LazyWrapper.prototype[methodName] = function() {
  17520. return this[takeName](1).value()[0];
  17521. };
  17522. });
  17523. // Add `LazyWrapper` methods for `_.initial` and `_.tail`.
  17524. arrayEach(['initial', 'tail'], function(methodName, index) {
  17525. var dropName = 'drop' + (index ? '' : 'Right');
  17526. LazyWrapper.prototype[methodName] = function() {
  17527. return this.__filtered__ ? new LazyWrapper(this) : this[dropName](1);
  17528. };
  17529. });
  17530. LazyWrapper.prototype.compact = function() {
  17531. return this.filter(identity);
  17532. };
  17533. LazyWrapper.prototype.find = function(predicate) {
  17534. return this.filter(predicate).head();
  17535. };
  17536. LazyWrapper.prototype.findLast = function(predicate) {
  17537. return this.reverse().find(predicate);
  17538. };
  17539. LazyWrapper.prototype.invokeMap = baseRest(function(path, args) {
  17540. if (typeof path == 'function') {
  17541. return new LazyWrapper(this);
  17542. }
  17543. return this.map(function(value) {
  17544. return baseInvoke(value, path, args);
  17545. });
  17546. });
  17547. LazyWrapper.prototype.reject = function(predicate) {
  17548. return this.filter(negate(getIteratee(predicate)));
  17549. };
  17550. LazyWrapper.prototype.slice = function(start, end) {
  17551. start = toInteger(start);
  17552. var result = this;
  17553. if (result.__filtered__ && (start > 0 || end < 0)) {
  17554. return new LazyWrapper(result);
  17555. }
  17556. if (start < 0) {
  17557. result = result.takeRight(-start);
  17558. } else if (start) {
  17559. result = result.drop(start);
  17560. }
  17561. if (end !== undefined) {
  17562. end = toInteger(end);
  17563. result = end < 0 ? result.dropRight(-end) : result.take(end - start);
  17564. }
  17565. return result;
  17566. };
  17567. LazyWrapper.prototype.takeRightWhile = function(predicate) {
  17568. return this.reverse().takeWhile(predicate).reverse();
  17569. };
  17570. LazyWrapper.prototype.toArray = function() {
  17571. return this.take(MAX_ARRAY_LENGTH);
  17572. };
  17573. // Add `LazyWrapper` methods to `lodash.prototype`.
  17574. baseForOwn(LazyWrapper.prototype, function(func, methodName) {
  17575. var checkIteratee = /^(?:filter|find|map|reject)|While$/.test(methodName),
  17576. isTaker = /^(?:head|last)$/.test(methodName),
  17577. lodashFunc = lodash[isTaker ? ('take' + (methodName == 'last' ? 'Right' : '')) : methodName],
  17578. retUnwrapped = isTaker || /^find/.test(methodName);
  17579. if (!lodashFunc) {
  17580. return;
  17581. }
  17582. lodash.prototype[methodName] = function() {
  17583. var value = this.__wrapped__,
  17584. args = isTaker ? [1] : arguments,
  17585. isLazy = value instanceof LazyWrapper,
  17586. iteratee = args[0],
  17587. useLazy = isLazy || isArray(value);
  17588. var interceptor = function(value) {
  17589. var result = lodashFunc.apply(lodash, arrayPush([value], args));
  17590. return (isTaker && chainAll) ? result[0] : result;
  17591. };
  17592. if (useLazy && checkIteratee && typeof iteratee == 'function' && iteratee.length != 1) {
  17593. // Avoid lazy use if the iteratee has a "length" value other than `1`.
  17594. isLazy = useLazy = false;
  17595. }
  17596. var chainAll = this.__chain__,
  17597. isHybrid = !!this.__actions__.length,
  17598. isUnwrapped = retUnwrapped && !chainAll,
  17599. onlyLazy = isLazy && !isHybrid;
  17600. if (!retUnwrapped && useLazy) {
  17601. value = onlyLazy ? value : new LazyWrapper(this);
  17602. var result = func.apply(value, args);
  17603. result.__actions__.push({ 'func': thru, 'args': [interceptor], 'thisArg': undefined });
  17604. return new LodashWrapper(result, chainAll);
  17605. }
  17606. if (isUnwrapped && onlyLazy) {
  17607. return func.apply(this, args);
  17608. }
  17609. result = this.thru(interceptor);
  17610. return isUnwrapped ? (isTaker ? result.value()[0] : result.value()) : result;
  17611. };
  17612. });
  17613. // Add `Array` methods to `lodash.prototype`.
  17614. arrayEach(['pop', 'push', 'shift', 'sort', 'splice', 'unshift'], function(methodName) {
  17615. var func = arrayProto[methodName],
  17616. chainName = /^(?:push|sort|unshift)$/.test(methodName) ? 'tap' : 'thru',
  17617. retUnwrapped = /^(?:pop|shift)$/.test(methodName);
  17618. lodash.prototype[methodName] = function() {
  17619. var args = arguments;
  17620. if (retUnwrapped && !this.__chain__) {
  17621. var value = this.value();
  17622. return func.apply(isArray(value) ? value : [], args);
  17623. }
  17624. return this[chainName](function(value) {
  17625. return func.apply(isArray(value) ? value : [], args);
  17626. });
  17627. };
  17628. });
  17629. // Map minified method names to their real names.
  17630. baseForOwn(LazyWrapper.prototype, function(func, methodName) {
  17631. var lodashFunc = lodash[methodName];
  17632. if (lodashFunc) {
  17633. var key = lodashFunc.name + '';
  17634. if (!hasOwnProperty.call(realNames, key)) {
  17635. realNames[key] = [];
  17636. }
  17637. realNames[key].push({ 'name': methodName, 'func': lodashFunc });
  17638. }
  17639. });
  17640. realNames[createHybrid(undefined, WRAP_BIND_KEY_FLAG).name] = [{
  17641. 'name': 'wrapper',
  17642. 'func': undefined
  17643. }];
  17644. // Add methods to `LazyWrapper`.
  17645. LazyWrapper.prototype.clone = lazyClone;
  17646. LazyWrapper.prototype.reverse = lazyReverse;
  17647. LazyWrapper.prototype.value = lazyValue;
  17648. // Add chain sequence methods to the `lodash` wrapper.
  17649. lodash.prototype.at = wrapperAt;
  17650. lodash.prototype.chain = wrapperChain;
  17651. lodash.prototype.commit = wrapperCommit;
  17652. lodash.prototype.next = wrapperNext;
  17653. lodash.prototype.plant = wrapperPlant;
  17654. lodash.prototype.reverse = wrapperReverse;
  17655. lodash.prototype.toJSON = lodash.prototype.valueOf = lodash.prototype.value = wrapperValue;
  17656. // Add lazy aliases.
  17657. lodash.prototype.first = lodash.prototype.head;
  17658. if (symIterator) {
  17659. lodash.prototype[symIterator] = wrapperToIterator;
  17660. }
  17661. return lodash;
  17662. });
  17663. /*--------------------------------------------------------------------------*/
  17664. // Export lodash.
  17665. var _ = runInContext();
  17666. // Some AMD build optimizers, like r.js, check for condition patterns like:
  17667. if (true) {
  17668. // Expose Lodash on the global object to prevent errors when Lodash is
  17669. // loaded by a script tag in the presence of an AMD loader.
  17670. // See http://requirejs.org/docs/errors.html#mismatch for more details.
  17671. // Use `_.noConflict` to remove Lodash from the global object.
  17672. root._ = _;
  17673. // Define as an anonymous module so, through path mapping, it can be
  17674. // referenced as the "underscore" module.
  17675. !(__WEBPACK_AMD_DEFINE_RESULT__ = (function() {
  17676. return _;
  17677. }).call(exports, __webpack_require__, exports, module),
  17678. __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));
  17679. }
  17680. // Check for `exports` after `define` in case a build optimizer adds it.
  17681. else {}
  17682. }.call(this));
  17683. /* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! ./../webpack/buildin/global.js */ "./node_modules/webpack/buildin/global.js"), __webpack_require__(/*! ./../webpack/buildin/module.js */ "./node_modules/webpack/buildin/module.js")(module)))
  17684. /***/ }),
  17685. /***/ "./node_modules/process/browser.js":
  17686. /*!*****************************************!*\
  17687. !*** ./node_modules/process/browser.js ***!
  17688. \*****************************************/
  17689. /*! no static exports found */
  17690. /***/ (function(module, exports) {
  17691. // shim for using process in browser
  17692. var process = module.exports = {};
  17693. // cached from whatever global is present so that test runners that stub it
  17694. // don't break things. But we need to wrap it in a try catch in case it is
  17695. // wrapped in strict mode code which doesn't define any globals. It's inside a
  17696. // function because try/catches deoptimize in certain engines.
  17697. var cachedSetTimeout;
  17698. var cachedClearTimeout;
  17699. function defaultSetTimout() {
  17700. throw new Error('setTimeout has not been defined');
  17701. }
  17702. function defaultClearTimeout () {
  17703. throw new Error('clearTimeout has not been defined');
  17704. }
  17705. (function () {
  17706. try {
  17707. if (typeof setTimeout === 'function') {
  17708. cachedSetTimeout = setTimeout;
  17709. } else {
  17710. cachedSetTimeout = defaultSetTimout;
  17711. }
  17712. } catch (e) {
  17713. cachedSetTimeout = defaultSetTimout;
  17714. }
  17715. try {
  17716. if (typeof clearTimeout === 'function') {
  17717. cachedClearTimeout = clearTimeout;
  17718. } else {
  17719. cachedClearTimeout = defaultClearTimeout;
  17720. }
  17721. } catch (e) {
  17722. cachedClearTimeout = defaultClearTimeout;
  17723. }
  17724. } ())
  17725. function runTimeout(fun) {
  17726. if (cachedSetTimeout === setTimeout) {
  17727. //normal enviroments in sane situations
  17728. return setTimeout(fun, 0);
  17729. }
  17730. // if setTimeout wasn't available but was latter defined
  17731. if ((cachedSetTimeout === defaultSetTimout || !cachedSetTimeout) && setTimeout) {
  17732. cachedSetTimeout = setTimeout;
  17733. return setTimeout(fun, 0);
  17734. }
  17735. try {
  17736. // when when somebody has screwed with setTimeout but no I.E. maddness
  17737. return cachedSetTimeout(fun, 0);
  17738. } catch(e){
  17739. try {
  17740. // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally
  17741. return cachedSetTimeout.call(null, fun, 0);
  17742. } catch(e){
  17743. // 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
  17744. return cachedSetTimeout.call(this, fun, 0);
  17745. }
  17746. }
  17747. }
  17748. function runClearTimeout(marker) {
  17749. if (cachedClearTimeout === clearTimeout) {
  17750. //normal enviroments in sane situations
  17751. return clearTimeout(marker);
  17752. }
  17753. // if clearTimeout wasn't available but was latter defined
  17754. if ((cachedClearTimeout === defaultClearTimeout || !cachedClearTimeout) && clearTimeout) {
  17755. cachedClearTimeout = clearTimeout;
  17756. return clearTimeout(marker);
  17757. }
  17758. try {
  17759. // when when somebody has screwed with setTimeout but no I.E. maddness
  17760. return cachedClearTimeout(marker);
  17761. } catch (e){
  17762. try {
  17763. // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally
  17764. return cachedClearTimeout.call(null, marker);
  17765. } catch (e){
  17766. // 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.
  17767. // Some versions of I.E. have different rules for clearTimeout vs setTimeout
  17768. return cachedClearTimeout.call(this, marker);
  17769. }
  17770. }
  17771. }
  17772. var queue = [];
  17773. var draining = false;
  17774. var currentQueue;
  17775. var queueIndex = -1;
  17776. function cleanUpNextTick() {
  17777. if (!draining || !currentQueue) {
  17778. return;
  17779. }
  17780. draining = false;
  17781. if (currentQueue.length) {
  17782. queue = currentQueue.concat(queue);
  17783. } else {
  17784. queueIndex = -1;
  17785. }
  17786. if (queue.length) {
  17787. drainQueue();
  17788. }
  17789. }
  17790. function drainQueue() {
  17791. if (draining) {
  17792. return;
  17793. }
  17794. var timeout = runTimeout(cleanUpNextTick);
  17795. draining = true;
  17796. var len = queue.length;
  17797. while(len) {
  17798. currentQueue = queue;
  17799. queue = [];
  17800. while (++queueIndex < len) {
  17801. if (currentQueue) {
  17802. currentQueue[queueIndex].run();
  17803. }
  17804. }
  17805. queueIndex = -1;
  17806. len = queue.length;
  17807. }
  17808. currentQueue = null;
  17809. draining = false;
  17810. runClearTimeout(timeout);
  17811. }
  17812. process.nextTick = function (fun) {
  17813. var args = new Array(arguments.length - 1);
  17814. if (arguments.length > 1) {
  17815. for (var i = 1; i < arguments.length; i++) {
  17816. args[i - 1] = arguments[i];
  17817. }
  17818. }
  17819. queue.push(new Item(fun, args));
  17820. if (queue.length === 1 && !draining) {
  17821. runTimeout(drainQueue);
  17822. }
  17823. };
  17824. // v8 likes predictible objects
  17825. function Item(fun, array) {
  17826. this.fun = fun;
  17827. this.array = array;
  17828. }
  17829. Item.prototype.run = function () {
  17830. this.fun.apply(null, this.array);
  17831. };
  17832. process.title = 'browser';
  17833. process.browser = true;
  17834. process.env = {};
  17835. process.argv = [];
  17836. process.version = ''; // empty string to avoid regexp issues
  17837. process.versions = {};
  17838. function noop() {}
  17839. process.on = noop;
  17840. process.addListener = noop;
  17841. process.once = noop;
  17842. process.off = noop;
  17843. process.removeListener = noop;
  17844. process.removeAllListeners = noop;
  17845. process.emit = noop;
  17846. process.prependListener = noop;
  17847. process.prependOnceListener = noop;
  17848. process.listeners = function (name) { return [] }
  17849. process.binding = function (name) {
  17850. throw new Error('process.binding is not supported');
  17851. };
  17852. process.cwd = function () { return '/' };
  17853. process.chdir = function (dir) {
  17854. throw new Error('process.chdir is not supported');
  17855. };
  17856. process.umask = function() { return 0; };
  17857. /***/ }),
  17858. /***/ "./node_modules/webpack/buildin/global.js":
  17859. /*!***********************************!*\
  17860. !*** (webpack)/buildin/global.js ***!
  17861. \***********************************/
  17862. /*! no static exports found */
  17863. /***/ (function(module, exports) {
  17864. var g;
  17865. // This works in non-strict mode
  17866. g = (function() {
  17867. return this;
  17868. })();
  17869. try {
  17870. // This works if eval is allowed (see CSP)
  17871. g = g || new Function("return this")();
  17872. } catch (e) {
  17873. // This works if the window reference is available
  17874. if (typeof window === "object") g = window;
  17875. }
  17876. // g can still be undefined, but nothing to do about it...
  17877. // We return undefined, instead of nothing here, so it's
  17878. // easier to handle this case. if(!global) { ...}
  17879. module.exports = g;
  17880. /***/ }),
  17881. /***/ "./node_modules/webpack/buildin/module.js":
  17882. /*!***********************************!*\
  17883. !*** (webpack)/buildin/module.js ***!
  17884. \***********************************/
  17885. /*! no static exports found */
  17886. /***/ (function(module, exports) {
  17887. module.exports = function(module) {
  17888. if (!module.webpackPolyfill) {
  17889. module.deprecate = function() {};
  17890. module.paths = [];
  17891. // module.parent = undefined by default
  17892. if (!module.children) module.children = [];
  17893. Object.defineProperty(module, "loaded", {
  17894. enumerable: true,
  17895. get: function() {
  17896. return module.l;
  17897. }
  17898. });
  17899. Object.defineProperty(module, "id", {
  17900. enumerable: true,
  17901. get: function() {
  17902. return module.i;
  17903. }
  17904. });
  17905. module.webpackPolyfill = 1;
  17906. }
  17907. return module;
  17908. };
  17909. /***/ }),
  17910. /***/ "./resources/js/app.js":
  17911. /*!*****************************!*\
  17912. !*** ./resources/js/app.js ***!
  17913. \*****************************/
  17914. /*! no static exports found */
  17915. /***/ (function(module, exports, __webpack_require__) {
  17916. __webpack_require__(/*! ./bootstrap */ "./resources/js/bootstrap.js");
  17917. /***/ }),
  17918. /***/ "./resources/js/bootstrap.js":
  17919. /*!***********************************!*\
  17920. !*** ./resources/js/bootstrap.js ***!
  17921. \***********************************/
  17922. /*! no static exports found */
  17923. /***/ (function(module, exports, __webpack_require__) {
  17924. window._ = __webpack_require__(/*! lodash */ "./node_modules/lodash/lodash.js");
  17925. /**
  17926. * We'll load the axios HTTP library which allows us to easily issue requests
  17927. * to our Laravel back-end. This library automatically handles sending the
  17928. * CSRF token as a header based on the value of the "XSRF" token cookie.
  17929. */
  17930. window.axios = __webpack_require__(/*! axios */ "./node_modules/axios/index.js");
  17931. window.axios.defaults.headers.common['X-Requested-With'] = 'XMLHttpRequest';
  17932. /**
  17933. * Echo exposes an expressive API for subscribing to channels and listening
  17934. * for events that are broadcast by Laravel. Echo and event broadcasting
  17935. * allows your team to easily build robust real-time web applications.
  17936. */
  17937. // import Echo from 'laravel-echo';
  17938. // window.Pusher = require('pusher-js');
  17939. // window.Echo = new Echo({
  17940. // broadcaster: 'pusher',
  17941. // key: process.env.MIX_PUSHER_APP_KEY,
  17942. // cluster: process.env.MIX_PUSHER_APP_CLUSTER,
  17943. // forceTLS: true
  17944. // });
  17945. /***/ }),
  17946. /***/ "./resources/sass/app.scss":
  17947. /*!*********************************!*\
  17948. !*** ./resources/sass/app.scss ***!
  17949. \*********************************/
  17950. /*! no static exports found */
  17951. /***/ (function(module, exports) {
  17952. // removed by extract-text-webpack-plugin
  17953. /***/ }),
  17954. /***/ 0:
  17955. /*!*************************************************************!*\
  17956. !*** multi ./resources/js/app.js ./resources/sass/app.scss ***!
  17957. \*************************************************************/
  17958. /*! no static exports found */
  17959. /***/ (function(module, exports, __webpack_require__) {
  17960. __webpack_require__(/*! /Users/giuseppe/Sites/calcioa5anteprima/resources/js/app.js */"./resources/js/app.js");
  17961. module.exports = __webpack_require__(/*! /Users/giuseppe/Sites/calcioa5anteprima/resources/sass/app.scss */"./resources/sass/app.scss");
  17962. /***/ })
  17963. /******/ });