lodash.custom.js 148 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260
  1. /**
  2. * @license
  3. * Lodash (Custom Build) <https://lodash.com/>
  4. * Build: `lodash include="isUndefined,isFunction,toArray,includes,union,each,isString,merge,isObject,set" exports="node"`
  5. * Copyright JS Foundation and other contributors <https://js.foundation/>
  6. * Released under MIT license <https://lodash.com/license>
  7. * Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
  8. * Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
  9. */
  10. (function () {
  11. /** Used as a safe reference for `undefined` in pre-ES5 environments. */
  12. var undefined;
  13. /** Used as the semantic version number. */
  14. var VERSION = "4.17.4";
  15. /** Used as the size to enable large array optimizations. */
  16. var LARGE_ARRAY_SIZE = 200;
  17. /** Error message constants. */
  18. var FUNC_ERROR_TEXT = "Expected a function";
  19. /** Used to stand-in for `undefined` hash values. */
  20. var HASH_UNDEFINED = "__lodash_hash_undefined__";
  21. /** Used as the maximum memoize cache size. */
  22. var MAX_MEMOIZE_SIZE = 500;
  23. /** Used to compose bitmasks for cloning. */
  24. var CLONE_DEEP_FLAG = 1, CLONE_FLAT_FLAG = 2, CLONE_SYMBOLS_FLAG = 4;
  25. /** Used to compose bitmasks for value comparisons. */
  26. var COMPARE_PARTIAL_FLAG = 1, COMPARE_UNORDERED_FLAG = 2;
  27. /** Used to detect hot functions by number of calls within a span of milliseconds. */
  28. var HOT_COUNT = 800, HOT_SPAN = 16;
  29. /** Used as references for various `Number` constants. */
  30. var INFINITY = 1 / 0, MAX_SAFE_INTEGER = 9007199254740991, MAX_INTEGER = 1.7976931348623157e308, NAN = 0 / 0;
  31. /** `Object#toString` result references. */
  32. var argsTag = "[object Arguments]", arrayTag = "[object Array]", asyncTag = "[object AsyncFunction]", boolTag = "[object Boolean]", dateTag = "[object Date]", errorTag = "[object Error]", funcTag = "[object Function]", genTag = "[object GeneratorFunction]", mapTag = "[object Map]", numberTag = "[object Number]", nullTag = "[object Null]", objectTag = "[object Object]", promiseTag = "[object Promise]", proxyTag = "[object Proxy]", regexpTag = "[object RegExp]", setTag = "[object Set]", stringTag = "[object String]", symbolTag = "[object Symbol]", undefinedTag = "[object Undefined]", weakMapTag = "[object WeakMap]";
  33. var arrayBufferTag = "[object ArrayBuffer]", dataViewTag = "[object DataView]", float32Tag = "[object Float32Array]", float64Tag = "[object Float64Array]", int8Tag = "[object Int8Array]", int16Tag = "[object Int16Array]", int32Tag = "[object Int32Array]", uint8Tag = "[object Uint8Array]", uint8ClampedTag = "[object Uint8ClampedArray]", uint16Tag = "[object Uint16Array]", uint32Tag = "[object Uint32Array]";
  34. /** Used to match property names within property paths. */
  35. var reIsDeepProp = /\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/, reIsPlainProp = /^\w*$/, reLeadingDot = /^\./, rePropName = /[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g;
  36. /**
  37. * Used to match `RegExp`
  38. * [syntax characters](http://ecma-international.org/ecma-262/7.0/#sec-patterns).
  39. */
  40. var reRegExpChar = /[\\^$.*+?()[\]{}|]/g;
  41. /** Used to match leading and trailing whitespace. */
  42. var reTrim = /^\s+|\s+$/g;
  43. /** Used to match backslashes in property paths. */
  44. var reEscapeChar = /\\(\\)?/g;
  45. /** Used to match `RegExp` flags from their coerced string values. */
  46. var reFlags = /\w*$/;
  47. /** Used to detect bad signed hexadecimal string values. */
  48. var reIsBadHex = /^[-+]0x[0-9a-f]+$/i;
  49. /** Used to detect binary string values. */
  50. var reIsBinary = /^0b[01]+$/i;
  51. /** Used to detect host constructors (Safari). */
  52. var reIsHostCtor = /^\[object .+?Constructor\]$/;
  53. /** Used to detect octal string values. */
  54. var reIsOctal = /^0o[0-7]+$/i;
  55. /** Used to detect unsigned integer values. */
  56. var reIsUint = /^(?:0|[1-9]\d*)$/;
  57. /** Used to compose unicode character classes. */
  58. var rsAstralRange = "\\ud800-\\udfff", rsComboMarksRange = "\\u0300-\\u036f", reComboHalfMarksRange = "\\ufe20-\\ufe2f", rsComboSymbolsRange = "\\u20d0-\\u20ff", rsComboRange = rsComboMarksRange + reComboHalfMarksRange + rsComboSymbolsRange, rsVarRange = "\\ufe0e\\ufe0f";
  59. /** Used to compose unicode capture groups. */
  60. var rsAstral = "[" + rsAstralRange + "]", rsCombo = "[" + rsComboRange + "]", rsFitz = "\\ud83c[\\udffb-\\udfff]", rsModifier = "(?:" + rsCombo + "|" + rsFitz + ")", rsNonAstral = "[^" + rsAstralRange + "]", rsRegional = "(?:\\ud83c[\\udde6-\\uddff]){2}", rsSurrPair = "[\\ud800-\\udbff][\\udc00-\\udfff]", rsZWJ = "\\u200d";
  61. /** Used to compose unicode regexes. */
  62. var reOptMod = rsModifier + "?", rsOptVar = "[" + rsVarRange + "]?", rsOptJoin = "(?:" +
  63. rsZWJ +
  64. "(?:" +
  65. [rsNonAstral, rsRegional, rsSurrPair].join("|") +
  66. ")" +
  67. rsOptVar +
  68. reOptMod +
  69. ")*", rsSeq = rsOptVar + reOptMod + rsOptJoin, rsSymbol = "(?:" +
  70. [
  71. rsNonAstral + rsCombo + "?",
  72. rsCombo,
  73. rsRegional,
  74. rsSurrPair,
  75. rsAstral
  76. ].join("|") +
  77. ")";
  78. /** Used to match [string symbols](https://mathiasbynens.be/notes/javascript-unicode). */
  79. var reUnicode = RegExp(rsFitz + "(?=" + rsFitz + ")|" + rsSymbol + rsSeq, "g");
  80. /** 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/). */
  81. var reHasUnicode = RegExp("[" + rsZWJ + rsAstralRange + rsComboRange + rsVarRange + "]");
  82. /** Used to identify `toStringTag` values of typed arrays. */
  83. var typedArrayTags = {};
  84. typedArrayTags[float32Tag] = typedArrayTags[float64Tag] = typedArrayTags[int8Tag] = typedArrayTags[int16Tag] = typedArrayTags[int32Tag] = typedArrayTags[uint8Tag] = typedArrayTags[uint8ClampedTag] = typedArrayTags[uint16Tag] = typedArrayTags[uint32Tag] = true;
  85. typedArrayTags[argsTag] = typedArrayTags[arrayTag] = typedArrayTags[arrayBufferTag] = typedArrayTags[boolTag] = typedArrayTags[dataViewTag] = typedArrayTags[dateTag] = typedArrayTags[errorTag] = typedArrayTags[funcTag] = typedArrayTags[mapTag] = typedArrayTags[numberTag] = typedArrayTags[objectTag] = typedArrayTags[regexpTag] = typedArrayTags[setTag] = typedArrayTags[stringTag] = typedArrayTags[weakMapTag] = false;
  86. /** Used to identify `toStringTag` values supported by `_.clone`. */
  87. var cloneableTags = {};
  88. cloneableTags[argsTag] = cloneableTags[arrayTag] = cloneableTags[arrayBufferTag] = cloneableTags[dataViewTag] = cloneableTags[boolTag] = cloneableTags[dateTag] = cloneableTags[float32Tag] = cloneableTags[float64Tag] = cloneableTags[int8Tag] = cloneableTags[int16Tag] = cloneableTags[int32Tag] = cloneableTags[mapTag] = cloneableTags[numberTag] = cloneableTags[objectTag] = cloneableTags[regexpTag] = cloneableTags[setTag] = cloneableTags[stringTag] = cloneableTags[symbolTag] = cloneableTags[uint8Tag] = cloneableTags[uint8ClampedTag] = cloneableTags[uint16Tag] = cloneableTags[uint32Tag] = true;
  89. cloneableTags[errorTag] = cloneableTags[funcTag] = cloneableTags[weakMapTag] = false;
  90. /** Built-in method references without a dependency on `root`. */
  91. var freeParseInt = parseInt;
  92. /** Detect free variable `global` from Node.js. */
  93. var freeGlobal = typeof global == "object" &&
  94. global &&
  95. global.Object === Object &&
  96. global;
  97. /** Detect free variable `self`. */
  98. var freeSelf = typeof self == "object" && self && self.Object === Object && self;
  99. /** Used as a reference to the global object. */
  100. var root = freeGlobal || freeSelf || Function("return this")();
  101. /** Detect free variable `exports`. */
  102. var freeExports = typeof exports == "object" && exports && !exports.nodeType && exports;
  103. /** Detect free variable `module`. */
  104. var freeModule = freeExports &&
  105. typeof module == "object" &&
  106. module &&
  107. !module.nodeType &&
  108. module;
  109. /** Detect the popular CommonJS extension `module.exports`. */
  110. var moduleExports = freeModule && freeModule.exports === freeExports;
  111. /** Detect free variable `process` from Node.js. */
  112. var freeProcess = moduleExports && freeGlobal.process;
  113. /** Used to access faster Node.js helpers. */
  114. var nodeUtil = (function () {
  115. try {
  116. return (freeProcess &&
  117. freeProcess.binding &&
  118. freeProcess.binding("util"));
  119. }
  120. catch (e) { }
  121. })();
  122. /* Node.js helper references. */
  123. var nodeIsTypedArray = nodeUtil && nodeUtil.isTypedArray;
  124. /*--------------------------------------------------------------------------*/
  125. /**
  126. * Adds the key-value `pair` to `map`.
  127. *
  128. * @private
  129. * @param {Object} map The map to modify.
  130. * @param {Array} pair The key-value pair to add.
  131. * @returns {Object} Returns `map`.
  132. */
  133. function addMapEntry(map, pair) {
  134. // Don't return `map.set` because it's not chainable in IE 11.
  135. map.set(pair[0], pair[1]);
  136. return map;
  137. }
  138. /**
  139. * Adds `value` to `set`.
  140. *
  141. * @private
  142. * @param {Object} set The set to modify.
  143. * @param {*} value The value to add.
  144. * @returns {Object} Returns `set`.
  145. */
  146. function addSetEntry(set, value) {
  147. // Don't return `set.add` because it's not chainable in IE 11.
  148. set.add(value);
  149. return set;
  150. }
  151. /**
  152. * A faster alternative to `Function#apply`, this function invokes `func`
  153. * with the `this` binding of `thisArg` and the arguments of `args`.
  154. *
  155. * @private
  156. * @param {Function} func The function to invoke.
  157. * @param {*} thisArg The `this` binding of `func`.
  158. * @param {Array} args The arguments to invoke `func` with.
  159. * @returns {*} Returns the result of `func`.
  160. */
  161. function apply(func, thisArg, args) {
  162. switch (args.length) {
  163. case 0:
  164. return func.call(thisArg);
  165. case 1:
  166. return func.call(thisArg, args[0]);
  167. case 2:
  168. return func.call(thisArg, args[0], args[1]);
  169. case 3:
  170. return func.call(thisArg, args[0], args[1], args[2]);
  171. }
  172. return func.apply(thisArg, args);
  173. }
  174. /**
  175. * A specialized version of `_.forEach` for arrays without support for
  176. * iteratee shorthands.
  177. *
  178. * @private
  179. * @param {Array} [array] The array to iterate over.
  180. * @param {Function} iteratee The function invoked per iteration.
  181. * @returns {Array} Returns `array`.
  182. */
  183. function arrayEach(array, iteratee) {
  184. var index = -1, length = array == null ? 0 : array.length;
  185. while (++index < length) {
  186. if (iteratee(array[index], index, array) === false) {
  187. break;
  188. }
  189. }
  190. return array;
  191. }
  192. /**
  193. * A specialized version of `_.filter` for arrays without support for
  194. * iteratee shorthands.
  195. *
  196. * @private
  197. * @param {Array} [array] The array to iterate over.
  198. * @param {Function} predicate The function invoked per iteration.
  199. * @returns {Array} Returns the new filtered array.
  200. */
  201. function arrayFilter(array, predicate) {
  202. var index = -1, length = array == null ? 0 : array.length, resIndex = 0, result = [];
  203. while (++index < length) {
  204. var value = array[index];
  205. if (predicate(value, index, array)) {
  206. result[resIndex++] = value;
  207. }
  208. }
  209. return result;
  210. }
  211. /**
  212. * A specialized version of `_.includes` for arrays without support for
  213. * specifying an index to search from.
  214. *
  215. * @private
  216. * @param {Array} [array] The array to inspect.
  217. * @param {*} target The value to search for.
  218. * @returns {boolean} Returns `true` if `target` is found, else `false`.
  219. */
  220. function arrayIncludes(array, value) {
  221. var length = array == null ? 0 : array.length;
  222. return !!length && baseIndexOf(array, value, 0) > -1;
  223. }
  224. /**
  225. * This function is like `arrayIncludes` except that it accepts a comparator.
  226. *
  227. * @private
  228. * @param {Array} [array] The array to inspect.
  229. * @param {*} target The value to search for.
  230. * @param {Function} comparator The comparator invoked per element.
  231. * @returns {boolean} Returns `true` if `target` is found, else `false`.
  232. */
  233. function arrayIncludesWith(array, value, comparator) {
  234. var index = -1, length = array == null ? 0 : array.length;
  235. while (++index < length) {
  236. if (comparator(value, array[index])) {
  237. return true;
  238. }
  239. }
  240. return false;
  241. }
  242. /**
  243. * A specialized version of `_.map` for arrays without support for iteratee
  244. * shorthands.
  245. *
  246. * @private
  247. * @param {Array} [array] The array to iterate over.
  248. * @param {Function} iteratee The function invoked per iteration.
  249. * @returns {Array} Returns the new mapped array.
  250. */
  251. function arrayMap(array, iteratee) {
  252. var index = -1, length = array == null ? 0 : array.length, result = Array(length);
  253. while (++index < length) {
  254. result[index] = iteratee(array[index], index, array);
  255. }
  256. return result;
  257. }
  258. /**
  259. * Appends the elements of `values` to `array`.
  260. *
  261. * @private
  262. * @param {Array} array The array to modify.
  263. * @param {Array} values The values to append.
  264. * @returns {Array} Returns `array`.
  265. */
  266. function arrayPush(array, values) {
  267. var index = -1, length = values.length, offset = array.length;
  268. while (++index < length) {
  269. array[offset + index] = values[index];
  270. }
  271. return array;
  272. }
  273. /**
  274. * A specialized version of `_.reduce` for arrays without support for
  275. * iteratee shorthands.
  276. *
  277. * @private
  278. * @param {Array} [array] The array to iterate over.
  279. * @param {Function} iteratee The function invoked per iteration.
  280. * @param {*} [accumulator] The initial value.
  281. * @param {boolean} [initAccum] Specify using the first element of `array` as
  282. * the initial value.
  283. * @returns {*} Returns the accumulated value.
  284. */
  285. function arrayReduce(array, iteratee, accumulator, initAccum) {
  286. var index = -1, length = array == null ? 0 : array.length;
  287. if (initAccum && length) {
  288. accumulator = array[++index];
  289. }
  290. while (++index < length) {
  291. accumulator = iteratee(accumulator, array[index], index, array);
  292. }
  293. return accumulator;
  294. }
  295. /**
  296. * A specialized version of `_.some` for arrays without support for iteratee
  297. * shorthands.
  298. *
  299. * @private
  300. * @param {Array} [array] The array to iterate over.
  301. * @param {Function} predicate The function invoked per iteration.
  302. * @returns {boolean} Returns `true` if any element passes the predicate check,
  303. * else `false`.
  304. */
  305. function arraySome(array, predicate) {
  306. var index = -1, length = array == null ? 0 : array.length;
  307. while (++index < length) {
  308. if (predicate(array[index], index, array)) {
  309. return true;
  310. }
  311. }
  312. return false;
  313. }
  314. /**
  315. * Converts an ASCII `string` to an array.
  316. *
  317. * @private
  318. * @param {string} string The string to convert.
  319. * @returns {Array} Returns the converted array.
  320. */
  321. function asciiToArray(string) {
  322. return string.split("");
  323. }
  324. /**
  325. * The base implementation of `_.findIndex` and `_.findLastIndex` without
  326. * support for iteratee shorthands.
  327. *
  328. * @private
  329. * @param {Array} array The array to inspect.
  330. * @param {Function} predicate The function invoked per iteration.
  331. * @param {number} fromIndex The index to search from.
  332. * @param {boolean} [fromRight] Specify iterating from right to left.
  333. * @returns {number} Returns the index of the matched value, else `-1`.
  334. */
  335. function baseFindIndex(array, predicate, fromIndex, fromRight) {
  336. var length = array.length, index = fromIndex + (fromRight ? 1 : -1);
  337. while (fromRight ? index-- : ++index < length) {
  338. if (predicate(array[index], index, array)) {
  339. return index;
  340. }
  341. }
  342. return -1;
  343. }
  344. /**
  345. * The base implementation of `_.indexOf` without `fromIndex` bounds checks.
  346. *
  347. * @private
  348. * @param {Array} array The array to inspect.
  349. * @param {*} value The value to search for.
  350. * @param {number} fromIndex The index to search from.
  351. * @returns {number} Returns the index of the matched value, else `-1`.
  352. */
  353. function baseIndexOf(array, value, fromIndex) {
  354. return value === value
  355. ? strictIndexOf(array, value, fromIndex)
  356. : baseFindIndex(array, baseIsNaN, fromIndex);
  357. }
  358. /**
  359. * The base implementation of `_.isNaN` without support for number objects.
  360. *
  361. * @private
  362. * @param {*} value The value to check.
  363. * @returns {boolean} Returns `true` if `value` is `NaN`, else `false`.
  364. */
  365. function baseIsNaN(value) {
  366. return value !== value;
  367. }
  368. /**
  369. * The base implementation of `_.property` without support for deep paths.
  370. *
  371. * @private
  372. * @param {string} key The key of the property to get.
  373. * @returns {Function} Returns the new accessor function.
  374. */
  375. function baseProperty(key) {
  376. return function (object) {
  377. return object == null ? undefined : object[key];
  378. };
  379. }
  380. /**
  381. * The base implementation of `_.times` without support for iteratee shorthands
  382. * or max array length checks.
  383. *
  384. * @private
  385. * @param {number} n The number of times to invoke `iteratee`.
  386. * @param {Function} iteratee The function invoked per iteration.
  387. * @returns {Array} Returns the array of results.
  388. */
  389. function baseTimes(n, iteratee) {
  390. var index = -1, result = Array(n);
  391. while (++index < n) {
  392. result[index] = iteratee(index);
  393. }
  394. return result;
  395. }
  396. /**
  397. * The base implementation of `_.unary` without support for storing metadata.
  398. *
  399. * @private
  400. * @param {Function} func The function to cap arguments for.
  401. * @returns {Function} Returns the new capped function.
  402. */
  403. function baseUnary(func) {
  404. return function (value) {
  405. return func(value);
  406. };
  407. }
  408. /**
  409. * The base implementation of `_.values` and `_.valuesIn` which creates an
  410. * array of `object` property values corresponding to the property names
  411. * of `props`.
  412. *
  413. * @private
  414. * @param {Object} object The object to query.
  415. * @param {Array} props The property names to get values for.
  416. * @returns {Object} Returns the array of property values.
  417. */
  418. function baseValues(object, props) {
  419. return arrayMap(props, function (key) {
  420. return object[key];
  421. });
  422. }
  423. /**
  424. * Checks if a `cache` value for `key` exists.
  425. *
  426. * @private
  427. * @param {Object} cache The cache to query.
  428. * @param {string} key The key of the entry to check.
  429. * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
  430. */
  431. function cacheHas(cache, key) {
  432. return cache.has(key);
  433. }
  434. /**
  435. * Gets the value at `key` of `object`.
  436. *
  437. * @private
  438. * @param {Object} [object] The object to query.
  439. * @param {string} key The key of the property to get.
  440. * @returns {*} Returns the property value.
  441. */
  442. function getValue(object, key) {
  443. return object == null ? undefined : object[key];
  444. }
  445. /**
  446. * Checks if `string` contains Unicode symbols.
  447. *
  448. * @private
  449. * @param {string} string The string to inspect.
  450. * @returns {boolean} Returns `true` if a symbol is found, else `false`.
  451. */
  452. function hasUnicode(string) {
  453. return reHasUnicode.test(string);
  454. }
  455. /**
  456. * Converts `iterator` to an array.
  457. *
  458. * @private
  459. * @param {Object} iterator The iterator to convert.
  460. * @returns {Array} Returns the converted array.
  461. */
  462. function iteratorToArray(iterator) {
  463. var data, result = [];
  464. while (!(data = iterator.next()).done) {
  465. result.push(data.value);
  466. }
  467. return result;
  468. }
  469. /**
  470. * Converts `map` to its key-value pairs.
  471. *
  472. * @private
  473. * @param {Object} map The map to convert.
  474. * @returns {Array} Returns the key-value pairs.
  475. */
  476. function mapToArray(map) {
  477. var index = -1, result = Array(map.size);
  478. map.forEach(function (value, key) {
  479. result[++index] = [key, value];
  480. });
  481. return result;
  482. }
  483. /**
  484. * Creates a unary function that invokes `func` with its argument transformed.
  485. *
  486. * @private
  487. * @param {Function} func The function to wrap.
  488. * @param {Function} transform The argument transform.
  489. * @returns {Function} Returns the new function.
  490. */
  491. function overArg(func, transform) {
  492. return function (arg) {
  493. return func(transform(arg));
  494. };
  495. }
  496. /**
  497. * Converts `set` to an array of its values.
  498. *
  499. * @private
  500. * @param {Object} set The set to convert.
  501. * @returns {Array} Returns the values.
  502. */
  503. function setToArray(set) {
  504. var index = -1, result = Array(set.size);
  505. set.forEach(function (value) {
  506. result[++index] = value;
  507. });
  508. return result;
  509. }
  510. /**
  511. * A specialized version of `_.indexOf` which performs strict equality
  512. * comparisons of values, i.e. `===`.
  513. *
  514. * @private
  515. * @param {Array} array The array to inspect.
  516. * @param {*} value The value to search for.
  517. * @param {number} fromIndex The index to search from.
  518. * @returns {number} Returns the index of the matched value, else `-1`.
  519. */
  520. function strictIndexOf(array, value, fromIndex) {
  521. var index = fromIndex - 1, length = array.length;
  522. while (++index < length) {
  523. if (array[index] === value) {
  524. return index;
  525. }
  526. }
  527. return -1;
  528. }
  529. /**
  530. * Converts `string` to an array.
  531. *
  532. * @private
  533. * @param {string} string The string to convert.
  534. * @returns {Array} Returns the converted array.
  535. */
  536. function stringToArray(string) {
  537. return hasUnicode(string)
  538. ? unicodeToArray(string)
  539. : asciiToArray(string);
  540. }
  541. /**
  542. * Converts a Unicode `string` to an array.
  543. *
  544. * @private
  545. * @param {string} string The string to convert.
  546. * @returns {Array} Returns the converted array.
  547. */
  548. function unicodeToArray(string) {
  549. return string.match(reUnicode) || [];
  550. }
  551. /*--------------------------------------------------------------------------*/
  552. /** Used for built-in method references. */
  553. var arrayProto = Array.prototype, funcProto = Function.prototype, objectProto = Object.prototype;
  554. /** Used to detect overreaching core-js shims. */
  555. var coreJsData = root["__core-js_shared__"];
  556. /** Used to resolve the decompiled source of functions. */
  557. var funcToString = funcProto.toString;
  558. /** Used to check objects for own properties. */
  559. var hasOwnProperty = objectProto.hasOwnProperty;
  560. /** Used to detect methods masquerading as native. */
  561. var maskSrcKey = (function () {
  562. var uid = /[^.]+$/.exec((coreJsData && coreJsData.keys && coreJsData.keys.IE_PROTO) || "");
  563. return uid ? "Symbol(src)_1." + uid : "";
  564. })();
  565. /**
  566. * Used to resolve the
  567. * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
  568. * of values.
  569. */
  570. var nativeObjectToString = objectProto.toString;
  571. /** Used to infer the `Object` constructor. */
  572. var objectCtorString = funcToString.call(Object);
  573. /** Used to detect if a method is native. */
  574. var reIsNative = RegExp("^" +
  575. funcToString
  576. .call(hasOwnProperty)
  577. .replace(reRegExpChar, "\\$&")
  578. .replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, "$1.*?") +
  579. "$");
  580. /** Built-in value references. */
  581. var Buffer = moduleExports ? root.Buffer : undefined, Symbol = root.Symbol, Uint8Array = root.Uint8Array, allocUnsafe = Buffer ? Buffer.allocUnsafe : undefined, getPrototype = overArg(Object.getPrototypeOf, Object), objectCreate = Object.create, propertyIsEnumerable = objectProto.propertyIsEnumerable, splice = arrayProto.splice, spreadableSymbol = Symbol ? Symbol.isConcatSpreadable : undefined, symIterator = Symbol ? Symbol.iterator : undefined, symToStringTag = Symbol ? Symbol.toStringTag : undefined;
  582. var defineProperty = (function () {
  583. try {
  584. var func = getNative(Object, "defineProperty");
  585. func({}, "", {});
  586. return func;
  587. }
  588. catch (e) { }
  589. })();
  590. /* Built-in method references for those with the same name as other `lodash` methods. */
  591. var nativeGetSymbols = Object.getOwnPropertySymbols, nativeIsBuffer = Buffer ? Buffer.isBuffer : undefined, nativeKeys = overArg(Object.keys, Object), nativeMax = Math.max, nativeNow = Date.now;
  592. /* Built-in method references that are verified to be native. */
  593. var DataView = getNative(root, "DataView"), Map = getNative(root, "Map"), Promise = getNative(root, "Promise"), Set = getNative(root, "Set"), WeakMap = getNative(root, "WeakMap"), nativeCreate = getNative(Object, "create");
  594. /** Used to lookup unminified function names. */
  595. var realNames = {};
  596. /** Used to detect maps, sets, and weakmaps. */
  597. var dataViewCtorString = toSource(DataView), mapCtorString = toSource(Map), promiseCtorString = toSource(Promise), setCtorString = toSource(Set), weakMapCtorString = toSource(WeakMap);
  598. /** Used to convert symbols to primitives and strings. */
  599. var symbolProto = Symbol ? Symbol.prototype : undefined, symbolValueOf = symbolProto ? symbolProto.valueOf : undefined, symbolToString = symbolProto ? symbolProto.toString : undefined;
  600. /*------------------------------------------------------------------------*/
  601. /**
  602. * Creates a `lodash` object which wraps `value` to enable implicit method
  603. * chain sequences. Methods that operate on and return arrays, collections,
  604. * and functions can be chained together. Methods that retrieve a single value
  605. * or may return a primitive value will automatically end the chain sequence
  606. * and return the unwrapped value. Otherwise, the value must be unwrapped
  607. * with `_#value`.
  608. *
  609. * Explicit chain sequences, which must be unwrapped with `_#value`, may be
  610. * enabled using `_.chain`.
  611. *
  612. * The execution of chained methods is lazy, that is, it's deferred until
  613. * `_#value` is implicitly or explicitly called.
  614. *
  615. * Lazy evaluation allows several methods to support shortcut fusion.
  616. * Shortcut fusion is an optimization to merge iteratee calls; this avoids
  617. * the creation of intermediate arrays and can greatly reduce the number of
  618. * iteratee executions. Sections of a chain sequence qualify for shortcut
  619. * fusion if the section is applied to an array and iteratees accept only
  620. * one argument. The heuristic for whether a section qualifies for shortcut
  621. * fusion is subject to change.
  622. *
  623. * Chaining is supported in custom builds as long as the `_#value` method is
  624. * directly or indirectly included in the build.
  625. *
  626. * In addition to lodash methods, wrappers have `Array` and `String` methods.
  627. *
  628. * The wrapper `Array` methods are:
  629. * `concat`, `join`, `pop`, `push`, `shift`, `sort`, `splice`, and `unshift`
  630. *
  631. * The wrapper `String` methods are:
  632. * `replace` and `split`
  633. *
  634. * The wrapper methods that support shortcut fusion are:
  635. * `at`, `compact`, `drop`, `dropRight`, `dropWhile`, `filter`, `find`,
  636. * `findLast`, `head`, `initial`, `last`, `map`, `reject`, `reverse`, `slice`,
  637. * `tail`, `take`, `takeRight`, `takeRightWhile`, `takeWhile`, and `toArray`
  638. *
  639. * The chainable wrapper methods are:
  640. * `after`, `ary`, `assign`, `assignIn`, `assignInWith`, `assignWith`, `at`,
  641. * `before`, `bind`, `bindAll`, `bindKey`, `castArray`, `chain`, `chunk`,
  642. * `commit`, `compact`, `concat`, `conforms`, `constant`, `countBy`, `create`,
  643. * `curry`, `debounce`, `defaults`, `defaultsDeep`, `defer`, `delay`,
  644. * `difference`, `differenceBy`, `differenceWith`, `drop`, `dropRight`,
  645. * `dropRightWhile`, `dropWhile`, `extend`, `extendWith`, `fill`, `filter`,
  646. * `flatMap`, `flatMapDeep`, `flatMapDepth`, `flatten`, `flattenDeep`,
  647. * `flattenDepth`, `flip`, `flow`, `flowRight`, `fromPairs`, `functions`,
  648. * `functionsIn`, `groupBy`, `initial`, `intersection`, `intersectionBy`,
  649. * `intersectionWith`, `invert`, `invertBy`, `invokeMap`, `iteratee`, `keyBy`,
  650. * `keys`, `keysIn`, `map`, `mapKeys`, `mapValues`, `matches`, `matchesProperty`,
  651. * `memoize`, `merge`, `mergeWith`, `method`, `methodOf`, `mixin`, `negate`,
  652. * `nthArg`, `omit`, `omitBy`, `once`, `orderBy`, `over`, `overArgs`,
  653. * `overEvery`, `overSome`, `partial`, `partialRight`, `partition`, `pick`,
  654. * `pickBy`, `plant`, `property`, `propertyOf`, `pull`, `pullAll`, `pullAllBy`,
  655. * `pullAllWith`, `pullAt`, `push`, `range`, `rangeRight`, `rearg`, `reject`,
  656. * `remove`, `rest`, `reverse`, `sampleSize`, `set`, `setWith`, `shuffle`,
  657. * `slice`, `sort`, `sortBy`, `splice`, `spread`, `tail`, `take`, `takeRight`,
  658. * `takeRightWhile`, `takeWhile`, `tap`, `throttle`, `thru`, `toArray`,
  659. * `toPairs`, `toPairsIn`, `toPath`, `toPlainObject`, `transform`, `unary`,
  660. * `union`, `unionBy`, `unionWith`, `uniq`, `uniqBy`, `uniqWith`, `unset`,
  661. * `unshift`, `unzip`, `unzipWith`, `update`, `updateWith`, `values`,
  662. * `valuesIn`, `without`, `wrap`, `xor`, `xorBy`, `xorWith`, `zip`,
  663. * `zipObject`, `zipObjectDeep`, and `zipWith`
  664. *
  665. * The wrapper methods that are **not** chainable by default are:
  666. * `add`, `attempt`, `camelCase`, `capitalize`, `ceil`, `clamp`, `clone`,
  667. * `cloneDeep`, `cloneDeepWith`, `cloneWith`, `conformsTo`, `deburr`,
  668. * `defaultTo`, `divide`, `each`, `eachRight`, `endsWith`, `eq`, `escape`,
  669. * `escapeRegExp`, `every`, `find`, `findIndex`, `findKey`, `findLast`,
  670. * `findLastIndex`, `findLastKey`, `first`, `floor`, `forEach`, `forEachRight`,
  671. * `forIn`, `forInRight`, `forOwn`, `forOwnRight`, `get`, `gt`, `gte`, `has`,
  672. * `hasIn`, `head`, `identity`, `includes`, `indexOf`, `inRange`, `invoke`,
  673. * `isArguments`, `isArray`, `isArrayBuffer`, `isArrayLike`, `isArrayLikeObject`,
  674. * `isBoolean`, `isBuffer`, `isDate`, `isElement`, `isEmpty`, `isEqual`,
  675. * `isEqualWith`, `isError`, `isFinite`, `isFunction`, `isInteger`, `isLength`,
  676. * `isMap`, `isMatch`, `isMatchWith`, `isNaN`, `isNative`, `isNil`, `isNull`,
  677. * `isNumber`, `isObject`, `isObjectLike`, `isPlainObject`, `isRegExp`,
  678. * `isSafeInteger`, `isSet`, `isString`, `isUndefined`, `isTypedArray`,
  679. * `isWeakMap`, `isWeakSet`, `join`, `kebabCase`, `last`, `lastIndexOf`,
  680. * `lowerCase`, `lowerFirst`, `lt`, `lte`, `max`, `maxBy`, `mean`, `meanBy`,
  681. * `min`, `minBy`, `multiply`, `noConflict`, `noop`, `now`, `nth`, `pad`,
  682. * `padEnd`, `padStart`, `parseInt`, `pop`, `random`, `reduce`, `reduceRight`,
  683. * `repeat`, `result`, `round`, `runInContext`, `sample`, `shift`, `size`,
  684. * `snakeCase`, `some`, `sortedIndex`, `sortedIndexBy`, `sortedLastIndex`,
  685. * `sortedLastIndexBy`, `startCase`, `startsWith`, `stubArray`, `stubFalse`,
  686. * `stubObject`, `stubString`, `stubTrue`, `subtract`, `sum`, `sumBy`,
  687. * `template`, `times`, `toFinite`, `toInteger`, `toJSON`, `toLength`,
  688. * `toLower`, `toNumber`, `toSafeInteger`, `toString`, `toUpper`, `trim`,
  689. * `trimEnd`, `trimStart`, `truncate`, `unescape`, `uniqueId`, `upperCase`,
  690. * `upperFirst`, `value`, and `words`
  691. *
  692. * @name _
  693. * @constructor
  694. * @category Seq
  695. * @param {*} value The value to wrap in a `lodash` instance.
  696. * @returns {Object} Returns the new `lodash` wrapper instance.
  697. * @example
  698. *
  699. * function square(n) {
  700. * return n * n;
  701. * }
  702. *
  703. * var wrapped = _([1, 2, 3]);
  704. *
  705. * // Returns an unwrapped value.
  706. * wrapped.reduce(_.add);
  707. * // => 6
  708. *
  709. * // Returns a wrapped value.
  710. * var squares = wrapped.map(square);
  711. *
  712. * _.isArray(squares);
  713. * // => false
  714. *
  715. * _.isArray(squares.value());
  716. * // => true
  717. */
  718. function lodash() {
  719. // No operation performed.
  720. }
  721. /**
  722. * The base implementation of `_.create` without support for assigning
  723. * properties to the created object.
  724. *
  725. * @private
  726. * @param {Object} proto The object to inherit from.
  727. * @returns {Object} Returns the new object.
  728. */
  729. var baseCreate = (function () {
  730. function object() { }
  731. return function (proto) {
  732. if (!isObject(proto)) {
  733. return {};
  734. }
  735. if (objectCreate) {
  736. return objectCreate(proto);
  737. }
  738. object.prototype = proto;
  739. var result = new object();
  740. object.prototype = undefined;
  741. return result;
  742. };
  743. })();
  744. /*------------------------------------------------------------------------*/
  745. /**
  746. * Creates a hash object.
  747. *
  748. * @private
  749. * @constructor
  750. * @param {Array} [entries] The key-value pairs to cache.
  751. */
  752. function Hash(entries) {
  753. var index = -1, length = entries == null ? 0 : entries.length;
  754. this.clear();
  755. while (++index < length) {
  756. var entry = entries[index];
  757. this.set(entry[0], entry[1]);
  758. }
  759. }
  760. /**
  761. * Removes all key-value entries from the hash.
  762. *
  763. * @private
  764. * @name clear
  765. * @memberOf Hash
  766. */
  767. function hashClear() {
  768. this.__data__ = nativeCreate ? nativeCreate(null) : {};
  769. this.size = 0;
  770. }
  771. /**
  772. * Removes `key` and its value from the hash.
  773. *
  774. * @private
  775. * @name delete
  776. * @memberOf Hash
  777. * @param {Object} hash The hash to modify.
  778. * @param {string} key The key of the value to remove.
  779. * @returns {boolean} Returns `true` if the entry was removed, else `false`.
  780. */
  781. function hashDelete(key) {
  782. var result = this.has(key) && delete this.__data__[key];
  783. this.size -= result ? 1 : 0;
  784. return result;
  785. }
  786. /**
  787. * Gets the hash value for `key`.
  788. *
  789. * @private
  790. * @name get
  791. * @memberOf Hash
  792. * @param {string} key The key of the value to get.
  793. * @returns {*} Returns the entry value.
  794. */
  795. function hashGet(key) {
  796. var data = this.__data__;
  797. if (nativeCreate) {
  798. var result = data[key];
  799. return result === HASH_UNDEFINED ? undefined : result;
  800. }
  801. return hasOwnProperty.call(data, key) ? data[key] : undefined;
  802. }
  803. /**
  804. * Checks if a hash value for `key` exists.
  805. *
  806. * @private
  807. * @name has
  808. * @memberOf Hash
  809. * @param {string} key The key of the entry to check.
  810. * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
  811. */
  812. function hashHas(key) {
  813. var data = this.__data__;
  814. return nativeCreate
  815. ? data[key] !== undefined
  816. : hasOwnProperty.call(data, key);
  817. }
  818. /**
  819. * Sets the hash `key` to `value`.
  820. *
  821. * @private
  822. * @name set
  823. * @memberOf Hash
  824. * @param {string} key The key of the value to set.
  825. * @param {*} value The value to set.
  826. * @returns {Object} Returns the hash instance.
  827. */
  828. function hashSet(key, value) {
  829. var data = this.__data__;
  830. this.size += this.has(key) ? 0 : 1;
  831. data[key] =
  832. nativeCreate && value === undefined ? HASH_UNDEFINED : value;
  833. return this;
  834. }
  835. // Add methods to `Hash`.
  836. Hash.prototype.clear = hashClear;
  837. Hash.prototype["delete"] = hashDelete;
  838. Hash.prototype.get = hashGet;
  839. Hash.prototype.has = hashHas;
  840. Hash.prototype.set = hashSet;
  841. /*------------------------------------------------------------------------*/
  842. /**
  843. * Creates an list cache object.
  844. *
  845. * @private
  846. * @constructor
  847. * @param {Array} [entries] The key-value pairs to cache.
  848. */
  849. function ListCache(entries) {
  850. var index = -1, length = entries == null ? 0 : entries.length;
  851. this.clear();
  852. while (++index < length) {
  853. var entry = entries[index];
  854. this.set(entry[0], entry[1]);
  855. }
  856. }
  857. /**
  858. * Removes all key-value entries from the list cache.
  859. *
  860. * @private
  861. * @name clear
  862. * @memberOf ListCache
  863. */
  864. function listCacheClear() {
  865. this.__data__ = [];
  866. this.size = 0;
  867. }
  868. /**
  869. * Removes `key` and its value from the list cache.
  870. *
  871. * @private
  872. * @name delete
  873. * @memberOf ListCache
  874. * @param {string} key The key of the value to remove.
  875. * @returns {boolean} Returns `true` if the entry was removed, else `false`.
  876. */
  877. function listCacheDelete(key) {
  878. var data = this.__data__, index = assocIndexOf(data, key);
  879. if (index < 0) {
  880. return false;
  881. }
  882. var lastIndex = data.length - 1;
  883. if (index == lastIndex) {
  884. data.pop();
  885. }
  886. else {
  887. splice.call(data, index, 1);
  888. }
  889. --this.size;
  890. return true;
  891. }
  892. /**
  893. * Gets the list cache value for `key`.
  894. *
  895. * @private
  896. * @name get
  897. * @memberOf ListCache
  898. * @param {string} key The key of the value to get.
  899. * @returns {*} Returns the entry value.
  900. */
  901. function listCacheGet(key) {
  902. var data = this.__data__, index = assocIndexOf(data, key);
  903. return index < 0 ? undefined : data[index][1];
  904. }
  905. /**
  906. * Checks if a list cache value for `key` exists.
  907. *
  908. * @private
  909. * @name has
  910. * @memberOf ListCache
  911. * @param {string} key The key of the entry to check.
  912. * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
  913. */
  914. function listCacheHas(key) {
  915. return assocIndexOf(this.__data__, key) > -1;
  916. }
  917. /**
  918. * Sets the list cache `key` to `value`.
  919. *
  920. * @private
  921. * @name set
  922. * @memberOf ListCache
  923. * @param {string} key The key of the value to set.
  924. * @param {*} value The value to set.
  925. * @returns {Object} Returns the list cache instance.
  926. */
  927. function listCacheSet(key, value) {
  928. var data = this.__data__, index = assocIndexOf(data, key);
  929. if (index < 0) {
  930. ++this.size;
  931. data.push([key, value]);
  932. }
  933. else {
  934. data[index][1] = value;
  935. }
  936. return this;
  937. }
  938. // Add methods to `ListCache`.
  939. ListCache.prototype.clear = listCacheClear;
  940. ListCache.prototype["delete"] = listCacheDelete;
  941. ListCache.prototype.get = listCacheGet;
  942. ListCache.prototype.has = listCacheHas;
  943. ListCache.prototype.set = listCacheSet;
  944. /*------------------------------------------------------------------------*/
  945. /**
  946. * Creates a map cache object to store key-value pairs.
  947. *
  948. * @private
  949. * @constructor
  950. * @param {Array} [entries] The key-value pairs to cache.
  951. */
  952. function MapCache(entries) {
  953. var index = -1, length = entries == null ? 0 : entries.length;
  954. this.clear();
  955. while (++index < length) {
  956. var entry = entries[index];
  957. this.set(entry[0], entry[1]);
  958. }
  959. }
  960. /**
  961. * Removes all key-value entries from the map.
  962. *
  963. * @private
  964. * @name clear
  965. * @memberOf MapCache
  966. */
  967. function mapCacheClear() {
  968. this.size = 0;
  969. this.__data__ = {
  970. hash: new Hash(),
  971. map: new (Map || ListCache)(),
  972. string: new Hash()
  973. };
  974. }
  975. /**
  976. * Removes `key` and its value from the map.
  977. *
  978. * @private
  979. * @name delete
  980. * @memberOf MapCache
  981. * @param {string} key The key of the value to remove.
  982. * @returns {boolean} Returns `true` if the entry was removed, else `false`.
  983. */
  984. function mapCacheDelete(key) {
  985. var result = getMapData(this, key)["delete"](key);
  986. this.size -= result ? 1 : 0;
  987. return result;
  988. }
  989. /**
  990. * Gets the map value for `key`.
  991. *
  992. * @private
  993. * @name get
  994. * @memberOf MapCache
  995. * @param {string} key The key of the value to get.
  996. * @returns {*} Returns the entry value.
  997. */
  998. function mapCacheGet(key) {
  999. return getMapData(this, key).get(key);
  1000. }
  1001. /**
  1002. * Checks if a map value for `key` exists.
  1003. *
  1004. * @private
  1005. * @name has
  1006. * @memberOf MapCache
  1007. * @param {string} key The key of the entry to check.
  1008. * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
  1009. */
  1010. function mapCacheHas(key) {
  1011. return getMapData(this, key).has(key);
  1012. }
  1013. /**
  1014. * Sets the map `key` to `value`.
  1015. *
  1016. * @private
  1017. * @name set
  1018. * @memberOf MapCache
  1019. * @param {string} key The key of the value to set.
  1020. * @param {*} value The value to set.
  1021. * @returns {Object} Returns the map cache instance.
  1022. */
  1023. function mapCacheSet(key, value) {
  1024. var data = getMapData(this, key), size = data.size;
  1025. data.set(key, value);
  1026. this.size += data.size == size ? 0 : 1;
  1027. return this;
  1028. }
  1029. // Add methods to `MapCache`.
  1030. MapCache.prototype.clear = mapCacheClear;
  1031. MapCache.prototype["delete"] = mapCacheDelete;
  1032. MapCache.prototype.get = mapCacheGet;
  1033. MapCache.prototype.has = mapCacheHas;
  1034. MapCache.prototype.set = mapCacheSet;
  1035. /*------------------------------------------------------------------------*/
  1036. /**
  1037. *
  1038. * Creates an array cache object to store unique values.
  1039. *
  1040. * @private
  1041. * @constructor
  1042. * @param {Array} [values] The values to cache.
  1043. */
  1044. function SetCache(values) {
  1045. var index = -1, length = values == null ? 0 : values.length;
  1046. this.__data__ = new MapCache();
  1047. while (++index < length) {
  1048. this.add(values[index]);
  1049. }
  1050. }
  1051. /**
  1052. * Adds `value` to the array cache.
  1053. *
  1054. * @private
  1055. * @name add
  1056. * @memberOf SetCache
  1057. * @alias push
  1058. * @param {*} value The value to cache.
  1059. * @returns {Object} Returns the cache instance.
  1060. */
  1061. function setCacheAdd(value) {
  1062. this.__data__.set(value, HASH_UNDEFINED);
  1063. return this;
  1064. }
  1065. /**
  1066. * Checks if `value` is in the array cache.
  1067. *
  1068. * @private
  1069. * @name has
  1070. * @memberOf SetCache
  1071. * @param {*} value The value to search for.
  1072. * @returns {number} Returns `true` if `value` is found, else `false`.
  1073. */
  1074. function setCacheHas(value) {
  1075. return this.__data__.has(value);
  1076. }
  1077. // Add methods to `SetCache`.
  1078. SetCache.prototype.add = SetCache.prototype.push = setCacheAdd;
  1079. SetCache.prototype.has = setCacheHas;
  1080. /*------------------------------------------------------------------------*/
  1081. /**
  1082. * Creates a stack cache object to store key-value pairs.
  1083. *
  1084. * @private
  1085. * @constructor
  1086. * @param {Array} [entries] The key-value pairs to cache.
  1087. */
  1088. function Stack(entries) {
  1089. var data = (this.__data__ = new ListCache(entries));
  1090. this.size = data.size;
  1091. }
  1092. /**
  1093. * Removes all key-value entries from the stack.
  1094. *
  1095. * @private
  1096. * @name clear
  1097. * @memberOf Stack
  1098. */
  1099. function stackClear() {
  1100. this.__data__ = new ListCache();
  1101. this.size = 0;
  1102. }
  1103. /**
  1104. * Removes `key` and its value from the stack.
  1105. *
  1106. * @private
  1107. * @name delete
  1108. * @memberOf Stack
  1109. * @param {string} key The key of the value to remove.
  1110. * @returns {boolean} Returns `true` if the entry was removed, else `false`.
  1111. */
  1112. function stackDelete(key) {
  1113. var data = this.__data__, result = data["delete"](key);
  1114. this.size = data.size;
  1115. return result;
  1116. }
  1117. /**
  1118. * Gets the stack value for `key`.
  1119. *
  1120. * @private
  1121. * @name get
  1122. * @memberOf Stack
  1123. * @param {string} key The key of the value to get.
  1124. * @returns {*} Returns the entry value.
  1125. */
  1126. function stackGet(key) {
  1127. return this.__data__.get(key);
  1128. }
  1129. /**
  1130. * Checks if a stack value for `key` exists.
  1131. *
  1132. * @private
  1133. * @name has
  1134. * @memberOf Stack
  1135. * @param {string} key The key of the entry to check.
  1136. * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
  1137. */
  1138. function stackHas(key) {
  1139. return this.__data__.has(key);
  1140. }
  1141. /**
  1142. * Sets the stack `key` to `value`.
  1143. *
  1144. * @private
  1145. * @name set
  1146. * @memberOf Stack
  1147. * @param {string} key The key of the value to set.
  1148. * @param {*} value The value to set.
  1149. * @returns {Object} Returns the stack cache instance.
  1150. */
  1151. function stackSet(key, value) {
  1152. var data = this.__data__;
  1153. if (data instanceof ListCache) {
  1154. var pairs = data.__data__;
  1155. if (!Map || pairs.length < LARGE_ARRAY_SIZE - 1) {
  1156. pairs.push([key, value]);
  1157. this.size = ++data.size;
  1158. return this;
  1159. }
  1160. data = this.__data__ = new MapCache(pairs);
  1161. }
  1162. data.set(key, value);
  1163. this.size = data.size;
  1164. return this;
  1165. }
  1166. // Add methods to `Stack`.
  1167. Stack.prototype.clear = stackClear;
  1168. Stack.prototype["delete"] = stackDelete;
  1169. Stack.prototype.get = stackGet;
  1170. Stack.prototype.has = stackHas;
  1171. Stack.prototype.set = stackSet;
  1172. /*------------------------------------------------------------------------*/
  1173. /**
  1174. * Creates an array of the enumerable property names of the array-like `value`.
  1175. *
  1176. * @private
  1177. * @param {*} value The value to query.
  1178. * @param {boolean} inherited Specify returning inherited property names.
  1179. * @returns {Array} Returns the array of property names.
  1180. */
  1181. function arrayLikeKeys(value, inherited) {
  1182. var isArr = isArray(value), isArg = !isArr && isArguments(value), isBuff = !isArr && !isArg && isBuffer(value), isType = !isArr && !isArg && !isBuff && isTypedArray(value), skipIndexes = isArr || isArg || isBuff || isType, result = skipIndexes ? baseTimes(value.length, String) : [], length = result.length;
  1183. for (var key in value) {
  1184. if ((inherited || hasOwnProperty.call(value, key)) &&
  1185. !(skipIndexes &&
  1186. // Safari 9 has enumerable `arguments.length` in strict mode.
  1187. (key == "length" ||
  1188. // Node.js 0.10 has enumerable non-index properties on buffers.
  1189. (isBuff && (key == "offset" || key == "parent")) ||
  1190. // PhantomJS 2 has enumerable non-index properties on typed arrays.
  1191. (isType &&
  1192. (key == "buffer" ||
  1193. key == "byteLength" ||
  1194. key == "byteOffset")) ||
  1195. // Skip index properties.
  1196. isIndex(key, length)))) {
  1197. result.push(key);
  1198. }
  1199. }
  1200. return result;
  1201. }
  1202. /**
  1203. * This function is like `assignValue` except that it doesn't assign
  1204. * `undefined` values.
  1205. *
  1206. * @private
  1207. * @param {Object} object The object to modify.
  1208. * @param {string} key The key of the property to assign.
  1209. * @param {*} value The value to assign.
  1210. */
  1211. function assignMergeValue(object, key, value) {
  1212. if ((value !== undefined && !eq(object[key], value)) ||
  1213. (value === undefined && !(key in object))) {
  1214. baseAssignValue(object, key, value);
  1215. }
  1216. }
  1217. /**
  1218. * Assigns `value` to `key` of `object` if the existing value is not equivalent
  1219. * using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
  1220. * for equality comparisons.
  1221. *
  1222. * @private
  1223. * @param {Object} object The object to modify.
  1224. * @param {string} key The key of the property to assign.
  1225. * @param {*} value The value to assign.
  1226. */
  1227. function assignValue(object, key, value) {
  1228. var objValue = object[key];
  1229. if (!(hasOwnProperty.call(object, key) && eq(objValue, value)) ||
  1230. (value === undefined && !(key in object))) {
  1231. baseAssignValue(object, key, value);
  1232. }
  1233. }
  1234. /**
  1235. * Gets the index at which the `key` is found in `array` of key-value pairs.
  1236. *
  1237. * @private
  1238. * @param {Array} array The array to inspect.
  1239. * @param {*} key The key to search for.
  1240. * @returns {number} Returns the index of the matched value, else `-1`.
  1241. */
  1242. function assocIndexOf(array, key) {
  1243. var length = array.length;
  1244. while (length--) {
  1245. if (eq(array[length][0], key)) {
  1246. return length;
  1247. }
  1248. }
  1249. return -1;
  1250. }
  1251. /**
  1252. * The base implementation of `_.assign` without support for multiple sources
  1253. * or `customizer` functions.
  1254. *
  1255. * @private
  1256. * @param {Object} object The destination object.
  1257. * @param {Object} source The source object.
  1258. * @returns {Object} Returns `object`.
  1259. */
  1260. function baseAssign(object, source) {
  1261. return object && copyObject(source, keys(source), object);
  1262. }
  1263. /**
  1264. * The base implementation of `_.assignIn` without support for multiple sources
  1265. * or `customizer` functions.
  1266. *
  1267. * @private
  1268. * @param {Object} object The destination object.
  1269. * @param {Object} source The source object.
  1270. * @returns {Object} Returns `object`.
  1271. */
  1272. function baseAssignIn(object, source) {
  1273. return object && copyObject(source, keysIn(source), object);
  1274. }
  1275. /**
  1276. * The base implementation of `assignValue` and `assignMergeValue` without
  1277. * value checks.
  1278. *
  1279. * @private
  1280. * @param {Object} object The object to modify.
  1281. * @param {string} key The key of the property to assign.
  1282. * @param {*} value The value to assign.
  1283. */
  1284. function baseAssignValue(object, key, value) {
  1285. if (key == "__proto__" && defineProperty) {
  1286. defineProperty(object, key, {
  1287. configurable: true,
  1288. enumerable: true,
  1289. value: value,
  1290. writable: true
  1291. });
  1292. }
  1293. else {
  1294. object[key] = value;
  1295. }
  1296. }
  1297. /**
  1298. * The base implementation of `_.clone` and `_.cloneDeep` which tracks
  1299. * traversed objects.
  1300. *
  1301. * @private
  1302. * @param {*} value The value to clone.
  1303. * @param {boolean} bitmask The bitmask flags.
  1304. * 1 - Deep clone
  1305. * 2 - Flatten inherited properties
  1306. * 4 - Clone symbols
  1307. * @param {Function} [customizer] The function to customize cloning.
  1308. * @param {string} [key] The key of `value`.
  1309. * @param {Object} [object] The parent object of `value`.
  1310. * @param {Object} [stack] Tracks traversed objects and their clone counterparts.
  1311. * @returns {*} Returns the cloned value.
  1312. */
  1313. function baseClone(value, bitmask, customizer, key, object, stack) {
  1314. var result, isDeep = bitmask & CLONE_DEEP_FLAG, isFlat = bitmask & CLONE_FLAT_FLAG, isFull = bitmask & CLONE_SYMBOLS_FLAG;
  1315. if (customizer) {
  1316. result = object
  1317. ? customizer(value, key, object, stack)
  1318. : customizer(value);
  1319. }
  1320. if (result !== undefined) {
  1321. return result;
  1322. }
  1323. if (!isObject(value)) {
  1324. return value;
  1325. }
  1326. var isArr = isArray(value);
  1327. if (isArr) {
  1328. result = initCloneArray(value);
  1329. if (!isDeep) {
  1330. return copyArray(value, result);
  1331. }
  1332. }
  1333. else {
  1334. var tag = getTag(value), isFunc = tag == funcTag || tag == genTag;
  1335. if (isBuffer(value)) {
  1336. return cloneBuffer(value, isDeep);
  1337. }
  1338. if (tag == objectTag || tag == argsTag || (isFunc && !object)) {
  1339. result = isFlat || isFunc ? {} : initCloneObject(value);
  1340. if (!isDeep) {
  1341. return isFlat
  1342. ? copySymbolsIn(value, baseAssignIn(result, value))
  1343. : copySymbols(value, baseAssign(result, value));
  1344. }
  1345. }
  1346. else {
  1347. if (!cloneableTags[tag]) {
  1348. return object ? value : {};
  1349. }
  1350. result = initCloneByTag(value, tag, baseClone, isDeep);
  1351. }
  1352. }
  1353. // Check for circular references and return its corresponding clone.
  1354. stack || (stack = new Stack());
  1355. var stacked = stack.get(value);
  1356. if (stacked) {
  1357. return stacked;
  1358. }
  1359. stack.set(value, result);
  1360. var keysFunc = isFull
  1361. ? isFlat
  1362. ? getAllKeysIn
  1363. : getAllKeys
  1364. : isFlat
  1365. ? keysIn
  1366. : keys;
  1367. var props = isArr ? undefined : keysFunc(value);
  1368. arrayEach(props || value, function (subValue, key) {
  1369. if (props) {
  1370. key = subValue;
  1371. subValue = value[key];
  1372. }
  1373. // Recursively populate clone (susceptible to call stack limits).
  1374. assignValue(result, key, baseClone(subValue, bitmask, customizer, key, value, stack));
  1375. });
  1376. return result;
  1377. }
  1378. /**
  1379. * The base implementation of `_.forEach` without support for iteratee shorthands.
  1380. *
  1381. * @private
  1382. * @param {Array|Object} collection The collection to iterate over.
  1383. * @param {Function} iteratee The function invoked per iteration.
  1384. * @returns {Array|Object} Returns `collection`.
  1385. */
  1386. var baseEach = createBaseEach(baseForOwn);
  1387. /**
  1388. * The base implementation of `_.flatten` with support for restricting flattening.
  1389. *
  1390. * @private
  1391. * @param {Array} array The array to flatten.
  1392. * @param {number} depth The maximum recursion depth.
  1393. * @param {boolean} [predicate=isFlattenable] The function invoked per iteration.
  1394. * @param {boolean} [isStrict] Restrict to values that pass `predicate` checks.
  1395. * @param {Array} [result=[]] The initial result value.
  1396. * @returns {Array} Returns the new flattened array.
  1397. */
  1398. function baseFlatten(array, depth, predicate, isStrict, result) {
  1399. var index = -1, length = array.length;
  1400. predicate || (predicate = isFlattenable);
  1401. result || (result = []);
  1402. while (++index < length) {
  1403. var value = array[index];
  1404. if (depth > 0 && predicate(value)) {
  1405. if (depth > 1) {
  1406. // Recursively flatten arrays (susceptible to call stack limits).
  1407. baseFlatten(value, depth - 1, predicate, isStrict, result);
  1408. }
  1409. else {
  1410. arrayPush(result, value);
  1411. }
  1412. }
  1413. else if (!isStrict) {
  1414. result[result.length] = value;
  1415. }
  1416. }
  1417. return result;
  1418. }
  1419. /**
  1420. * The base implementation of `baseForOwn` which iterates over `object`
  1421. * properties returned by `keysFunc` and invokes `iteratee` for each property.
  1422. * Iteratee functions may exit iteration early by explicitly returning `false`.
  1423. *
  1424. * @private
  1425. * @param {Object} object The object to iterate over.
  1426. * @param {Function} iteratee The function invoked per iteration.
  1427. * @param {Function} keysFunc The function to get the keys of `object`.
  1428. * @returns {Object} Returns `object`.
  1429. */
  1430. var baseFor = createBaseFor();
  1431. /**
  1432. * The base implementation of `_.forOwn` without support for iteratee shorthands.
  1433. *
  1434. * @private
  1435. * @param {Object} object The object to iterate over.
  1436. * @param {Function} iteratee The function invoked per iteration.
  1437. * @returns {Object} Returns `object`.
  1438. */
  1439. function baseForOwn(object, iteratee) {
  1440. return object && baseFor(object, iteratee, keys);
  1441. }
  1442. /**
  1443. * The base implementation of `_.get` without support for default values.
  1444. *
  1445. * @private
  1446. * @param {Object} object The object to query.
  1447. * @param {Array|string} path The path of the property to get.
  1448. * @returns {*} Returns the resolved value.
  1449. */
  1450. function baseGet(object, path) {
  1451. path = castPath(path, object);
  1452. var index = 0, length = path.length;
  1453. while (object != null && index < length) {
  1454. object = object[toKey(path[index++])];
  1455. }
  1456. return index && index == length ? object : undefined;
  1457. }
  1458. /**
  1459. * The base implementation of `getAllKeys` and `getAllKeysIn` which uses
  1460. * `keysFunc` and `symbolsFunc` to get the enumerable property names and
  1461. * symbols of `object`.
  1462. *
  1463. * @private
  1464. * @param {Object} object The object to query.
  1465. * @param {Function} keysFunc The function to get the keys of `object`.
  1466. * @param {Function} symbolsFunc The function to get the symbols of `object`.
  1467. * @returns {Array} Returns the array of property names and symbols.
  1468. */
  1469. function baseGetAllKeys(object, keysFunc, symbolsFunc) {
  1470. var result = keysFunc(object);
  1471. return isArray(object)
  1472. ? result
  1473. : arrayPush(result, symbolsFunc(object));
  1474. }
  1475. /**
  1476. * The base implementation of `getTag` without fallbacks for buggy environments.
  1477. *
  1478. * @private
  1479. * @param {*} value The value to query.
  1480. * @returns {string} Returns the `toStringTag`.
  1481. */
  1482. function baseGetTag(value) {
  1483. if (value == null) {
  1484. return value === undefined ? undefinedTag : nullTag;
  1485. }
  1486. return symToStringTag && symToStringTag in Object(value)
  1487. ? getRawTag(value)
  1488. : objectToString(value);
  1489. }
  1490. /**
  1491. * The base implementation of `_.hasIn` without support for deep paths.
  1492. *
  1493. * @private
  1494. * @param {Object} [object] The object to query.
  1495. * @param {Array|string} key The key to check.
  1496. * @returns {boolean} Returns `true` if `key` exists, else `false`.
  1497. */
  1498. function baseHasIn(object, key) {
  1499. return object != null && key in Object(object);
  1500. }
  1501. /**
  1502. * The base implementation of `_.isArguments`.
  1503. *
  1504. * @private
  1505. * @param {*} value The value to check.
  1506. * @returns {boolean} Returns `true` if `value` is an `arguments` object,
  1507. */
  1508. function baseIsArguments(value) {
  1509. return isObjectLike(value) && baseGetTag(value) == argsTag;
  1510. }
  1511. /**
  1512. * The base implementation of `_.isEqual` which supports partial comparisons
  1513. * and tracks traversed objects.
  1514. *
  1515. * @private
  1516. * @param {*} value The value to compare.
  1517. * @param {*} other The other value to compare.
  1518. * @param {boolean} bitmask The bitmask flags.
  1519. * 1 - Unordered comparison
  1520. * 2 - Partial comparison
  1521. * @param {Function} [customizer] The function to customize comparisons.
  1522. * @param {Object} [stack] Tracks traversed `value` and `other` objects.
  1523. * @returns {boolean} Returns `true` if the values are equivalent, else `false`.
  1524. */
  1525. function baseIsEqual(value, other, bitmask, customizer, stack) {
  1526. if (value === other) {
  1527. return true;
  1528. }
  1529. if (value == null ||
  1530. other == null ||
  1531. (!isObjectLike(value) && !isObjectLike(other))) {
  1532. return value !== value && other !== other;
  1533. }
  1534. return baseIsEqualDeep(value, other, bitmask, customizer, baseIsEqual, stack);
  1535. }
  1536. /**
  1537. * A specialized version of `baseIsEqual` for arrays and objects which performs
  1538. * deep comparisons and tracks traversed objects enabling objects with circular
  1539. * references to be compared.
  1540. *
  1541. * @private
  1542. * @param {Object} object The object to compare.
  1543. * @param {Object} other The other object to compare.
  1544. * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.
  1545. * @param {Function} customizer The function to customize comparisons.
  1546. * @param {Function} equalFunc The function to determine equivalents of values.
  1547. * @param {Object} [stack] Tracks traversed `object` and `other` objects.
  1548. * @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
  1549. */
  1550. function baseIsEqualDeep(object, other, bitmask, customizer, equalFunc, stack) {
  1551. var objIsArr = isArray(object), othIsArr = isArray(other), objTag = objIsArr ? arrayTag : getTag(object), othTag = othIsArr ? arrayTag : getTag(other);
  1552. objTag = objTag == argsTag ? objectTag : objTag;
  1553. othTag = othTag == argsTag ? objectTag : othTag;
  1554. var objIsObj = objTag == objectTag, othIsObj = othTag == objectTag, isSameTag = objTag == othTag;
  1555. if (isSameTag && isBuffer(object)) {
  1556. if (!isBuffer(other)) {
  1557. return false;
  1558. }
  1559. objIsArr = true;
  1560. objIsObj = false;
  1561. }
  1562. if (isSameTag && !objIsObj) {
  1563. stack || (stack = new Stack());
  1564. return objIsArr || isTypedArray(object)
  1565. ? equalArrays(object, other, bitmask, customizer, equalFunc, stack)
  1566. : equalByTag(object, other, objTag, bitmask, customizer, equalFunc, stack);
  1567. }
  1568. if (!(bitmask & COMPARE_PARTIAL_FLAG)) {
  1569. var objIsWrapped = objIsObj && hasOwnProperty.call(object, "__wrapped__"), othIsWrapped = othIsObj && hasOwnProperty.call(other, "__wrapped__");
  1570. if (objIsWrapped || othIsWrapped) {
  1571. var objUnwrapped = objIsWrapped ? object.value() : object, othUnwrapped = othIsWrapped ? other.value() : other;
  1572. stack || (stack = new Stack());
  1573. return equalFunc(objUnwrapped, othUnwrapped, bitmask, customizer, stack);
  1574. }
  1575. }
  1576. if (!isSameTag) {
  1577. return false;
  1578. }
  1579. stack || (stack = new Stack());
  1580. return equalObjects(object, other, bitmask, customizer, equalFunc, stack);
  1581. }
  1582. /**
  1583. * The base implementation of `_.isMatch` without support for iteratee shorthands.
  1584. *
  1585. * @private
  1586. * @param {Object} object The object to inspect.
  1587. * @param {Object} source The object of property values to match.
  1588. * @param {Array} matchData The property names, values, and compare flags to match.
  1589. * @param {Function} [customizer] The function to customize comparisons.
  1590. * @returns {boolean} Returns `true` if `object` is a match, else `false`.
  1591. */
  1592. function baseIsMatch(object, source, matchData, customizer) {
  1593. var index = matchData.length, length = index, noCustomizer = !customizer;
  1594. if (object == null) {
  1595. return !length;
  1596. }
  1597. object = Object(object);
  1598. while (index--) {
  1599. var data = matchData[index];
  1600. if (noCustomizer && data[2]
  1601. ? data[1] !== object[data[0]]
  1602. : !(data[0] in object)) {
  1603. return false;
  1604. }
  1605. }
  1606. while (++index < length) {
  1607. data = matchData[index];
  1608. var key = data[0], objValue = object[key], srcValue = data[1];
  1609. if (noCustomizer && data[2]) {
  1610. if (objValue === undefined && !(key in object)) {
  1611. return false;
  1612. }
  1613. }
  1614. else {
  1615. var stack = new Stack();
  1616. if (customizer) {
  1617. var result = customizer(objValue, srcValue, key, object, source, stack);
  1618. }
  1619. if (!(result === undefined
  1620. ? baseIsEqual(srcValue, objValue, COMPARE_PARTIAL_FLAG | COMPARE_UNORDERED_FLAG, customizer, stack)
  1621. : result)) {
  1622. return false;
  1623. }
  1624. }
  1625. }
  1626. return true;
  1627. }
  1628. /**
  1629. * The base implementation of `_.isNative` without bad shim checks.
  1630. *
  1631. * @private
  1632. * @param {*} value The value to check.
  1633. * @returns {boolean} Returns `true` if `value` is a native function,
  1634. * else `false`.
  1635. */
  1636. function baseIsNative(value) {
  1637. if (!isObject(value) || isMasked(value)) {
  1638. return false;
  1639. }
  1640. var pattern = isFunction(value) ? reIsNative : reIsHostCtor;
  1641. return pattern.test(toSource(value));
  1642. }
  1643. /**
  1644. * The base implementation of `_.isTypedArray` without Node.js optimizations.
  1645. *
  1646. * @private
  1647. * @param {*} value The value to check.
  1648. * @returns {boolean} Returns `true` if `value` is a typed array, else `false`.
  1649. */
  1650. function baseIsTypedArray(value) {
  1651. return (isObjectLike(value) &&
  1652. isLength(value.length) &&
  1653. !!typedArrayTags[baseGetTag(value)]);
  1654. }
  1655. /**
  1656. * The base implementation of `_.iteratee`.
  1657. *
  1658. * @private
  1659. * @param {*} [value=_.identity] The value to convert to an iteratee.
  1660. * @returns {Function} Returns the iteratee.
  1661. */
  1662. function baseIteratee(value) {
  1663. // Don't store the `typeof` result in a variable to avoid a JIT bug in Safari 9.
  1664. // See https://bugs.webkit.org/show_bug.cgi?id=156034 for more details.
  1665. if (typeof value == "function") {
  1666. return value;
  1667. }
  1668. if (value == null) {
  1669. return identity;
  1670. }
  1671. if (typeof value == "object") {
  1672. return isArray(value)
  1673. ? baseMatchesProperty(value[0], value[1])
  1674. : baseMatches(value);
  1675. }
  1676. return property(value);
  1677. }
  1678. /**
  1679. * The base implementation of `_.keys` which doesn't treat sparse arrays as dense.
  1680. *
  1681. * @private
  1682. * @param {Object} object The object to query.
  1683. * @returns {Array} Returns the array of property names.
  1684. */
  1685. function baseKeys(object) {
  1686. if (!isPrototype(object)) {
  1687. return nativeKeys(object);
  1688. }
  1689. var result = [];
  1690. for (var key in Object(object)) {
  1691. if (hasOwnProperty.call(object, key) && key != "constructor") {
  1692. result.push(key);
  1693. }
  1694. }
  1695. return result;
  1696. }
  1697. /**
  1698. * The base implementation of `_.keysIn` which doesn't treat sparse arrays as dense.
  1699. *
  1700. * @private
  1701. * @param {Object} object The object to query.
  1702. * @returns {Array} Returns the array of property names.
  1703. */
  1704. function baseKeysIn(object) {
  1705. if (!isObject(object)) {
  1706. return nativeKeysIn(object);
  1707. }
  1708. var isProto = isPrototype(object), result = [];
  1709. for (var key in object) {
  1710. if (!(key == "constructor" &&
  1711. (isProto || !hasOwnProperty.call(object, key)))) {
  1712. result.push(key);
  1713. }
  1714. }
  1715. return result;
  1716. }
  1717. /**
  1718. * The base implementation of `_.matches` which doesn't clone `source`.
  1719. *
  1720. * @private
  1721. * @param {Object} source The object of property values to match.
  1722. * @returns {Function} Returns the new spec function.
  1723. */
  1724. function baseMatches(source) {
  1725. var matchData = getMatchData(source);
  1726. if (matchData.length == 1 && matchData[0][2]) {
  1727. return matchesStrictComparable(matchData[0][0], matchData[0][1]);
  1728. }
  1729. return function (object) {
  1730. return object === source || baseIsMatch(object, source, matchData);
  1731. };
  1732. }
  1733. /**
  1734. * The base implementation of `_.matchesProperty` which doesn't clone `srcValue`.
  1735. *
  1736. * @private
  1737. * @param {string} path The path of the property to get.
  1738. * @param {*} srcValue The value to match.
  1739. * @returns {Function} Returns the new spec function.
  1740. */
  1741. function baseMatchesProperty(path, srcValue) {
  1742. if (isKey(path) && isStrictComparable(srcValue)) {
  1743. return matchesStrictComparable(toKey(path), srcValue);
  1744. }
  1745. return function (object) {
  1746. var objValue = get(object, path);
  1747. return objValue === undefined && objValue === srcValue
  1748. ? hasIn(object, path)
  1749. : baseIsEqual(srcValue, objValue, COMPARE_PARTIAL_FLAG | COMPARE_UNORDERED_FLAG);
  1750. };
  1751. }
  1752. /**
  1753. * The base implementation of `_.merge` without support for multiple sources.
  1754. *
  1755. * @private
  1756. * @param {Object} object The destination object.
  1757. * @param {Object} source The source object.
  1758. * @param {number} srcIndex The index of `source`.
  1759. * @param {Function} [customizer] The function to customize merged values.
  1760. * @param {Object} [stack] Tracks traversed source values and their merged
  1761. * counterparts.
  1762. */
  1763. function baseMerge(object, source, srcIndex, customizer, stack) {
  1764. if (object === source) {
  1765. return;
  1766. }
  1767. baseFor(source, function (srcValue, key) {
  1768. if (isObject(srcValue)) {
  1769. stack || (stack = new Stack());
  1770. baseMergeDeep(object, source, key, srcIndex, baseMerge, customizer, stack);
  1771. }
  1772. else {
  1773. var newValue = customizer
  1774. ? customizer(object[key], srcValue, key + "", object, source, stack)
  1775. : undefined;
  1776. if (newValue === undefined) {
  1777. newValue = srcValue;
  1778. }
  1779. assignMergeValue(object, key, newValue);
  1780. }
  1781. }, keysIn);
  1782. }
  1783. /**
  1784. * A specialized version of `baseMerge` for arrays and objects which performs
  1785. * deep merges and tracks traversed objects enabling objects with circular
  1786. * references to be merged.
  1787. *
  1788. * @private
  1789. * @param {Object} object The destination object.
  1790. * @param {Object} source The source object.
  1791. * @param {string} key The key of the value to merge.
  1792. * @param {number} srcIndex The index of `source`.
  1793. * @param {Function} mergeFunc The function to merge values.
  1794. * @param {Function} [customizer] The function to customize assigned values.
  1795. * @param {Object} [stack] Tracks traversed source values and their merged
  1796. * counterparts.
  1797. */
  1798. function baseMergeDeep(object, source, key, srcIndex, mergeFunc, customizer, stack) {
  1799. var objValue = object[key], srcValue = source[key], stacked = stack.get(srcValue);
  1800. if (stacked) {
  1801. assignMergeValue(object, key, stacked);
  1802. return;
  1803. }
  1804. var newValue = customizer
  1805. ? customizer(objValue, srcValue, key + "", object, source, stack)
  1806. : undefined;
  1807. var isCommon = newValue === undefined;
  1808. if (isCommon) {
  1809. var isArr = isArray(srcValue), isBuff = !isArr && isBuffer(srcValue), isTyped = !isArr && !isBuff && isTypedArray(srcValue);
  1810. newValue = srcValue;
  1811. if (isArr || isBuff || isTyped) {
  1812. if (isArray(objValue)) {
  1813. newValue = objValue;
  1814. }
  1815. else if (isArrayLikeObject(objValue)) {
  1816. newValue = copyArray(objValue);
  1817. }
  1818. else if (isBuff) {
  1819. isCommon = false;
  1820. newValue = cloneBuffer(srcValue, true);
  1821. }
  1822. else if (isTyped) {
  1823. isCommon = false;
  1824. newValue = cloneTypedArray(srcValue, true);
  1825. }
  1826. else {
  1827. newValue = [];
  1828. }
  1829. }
  1830. else if (isPlainObject(srcValue) || isArguments(srcValue)) {
  1831. newValue = objValue;
  1832. if (isArguments(objValue)) {
  1833. newValue = toPlainObject(objValue);
  1834. }
  1835. else if (!isObject(objValue) ||
  1836. (srcIndex && isFunction(objValue))) {
  1837. newValue = initCloneObject(srcValue);
  1838. }
  1839. }
  1840. else {
  1841. isCommon = false;
  1842. }
  1843. }
  1844. if (isCommon) {
  1845. // Recursively merge objects and arrays (susceptible to call stack limits).
  1846. stack.set(srcValue, newValue);
  1847. mergeFunc(newValue, srcValue, srcIndex, customizer, stack);
  1848. stack["delete"](srcValue);
  1849. }
  1850. assignMergeValue(object, key, newValue);
  1851. }
  1852. /**
  1853. * A specialized version of `baseProperty` which supports deep paths.
  1854. *
  1855. * @private
  1856. * @param {Array|string} path The path of the property to get.
  1857. * @returns {Function} Returns the new accessor function.
  1858. */
  1859. function basePropertyDeep(path) {
  1860. return function (object) {
  1861. return baseGet(object, path);
  1862. };
  1863. }
  1864. /**
  1865. * The base implementation of `_.rest` which doesn't validate or coerce arguments.
  1866. *
  1867. * @private
  1868. * @param {Function} func The function to apply a rest parameter to.
  1869. * @param {number} [start=func.length-1] The start position of the rest parameter.
  1870. * @returns {Function} Returns the new function.
  1871. */
  1872. function baseRest(func, start) {
  1873. return setToString(overRest(func, start, identity), func + "");
  1874. }
  1875. /**
  1876. * The base implementation of `_.set`.
  1877. *
  1878. * @private
  1879. * @param {Object} object The object to modify.
  1880. * @param {Array|string} path The path of the property to set.
  1881. * @param {*} value The value to set.
  1882. * @param {Function} [customizer] The function to customize path creation.
  1883. * @returns {Object} Returns `object`.
  1884. */
  1885. function baseSet(object, path, value, customizer) {
  1886. if (!isObject(object)) {
  1887. return object;
  1888. }
  1889. path = castPath(path, object);
  1890. var index = -1, length = path.length, lastIndex = length - 1, nested = object;
  1891. while (nested != null && ++index < length) {
  1892. var key = toKey(path[index]), newValue = value;
  1893. if (index != lastIndex) {
  1894. var objValue = nested[key];
  1895. newValue = customizer
  1896. ? customizer(objValue, key, nested)
  1897. : undefined;
  1898. if (newValue === undefined) {
  1899. newValue = isObject(objValue)
  1900. ? objValue
  1901. : isIndex(path[index + 1])
  1902. ? []
  1903. : {};
  1904. }
  1905. }
  1906. assignValue(nested, key, newValue);
  1907. nested = nested[key];
  1908. }
  1909. return object;
  1910. }
  1911. /**
  1912. * The base implementation of `setToString` without support for hot loop shorting.
  1913. *
  1914. * @private
  1915. * @param {Function} func The function to modify.
  1916. * @param {Function} string The `toString` result.
  1917. * @returns {Function} Returns `func`.
  1918. */
  1919. var baseSetToString = !defineProperty
  1920. ? identity
  1921. : function (func, string) {
  1922. return defineProperty(func, "toString", {
  1923. configurable: true,
  1924. enumerable: false,
  1925. value: constant(string),
  1926. writable: true
  1927. });
  1928. };
  1929. /**
  1930. * The base implementation of `_.toString` which doesn't convert nullish
  1931. * values to empty strings.
  1932. *
  1933. * @private
  1934. * @param {*} value The value to process.
  1935. * @returns {string} Returns the string.
  1936. */
  1937. function baseToString(value) {
  1938. // Exit early for strings to avoid a performance hit in some environments.
  1939. if (typeof value == "string") {
  1940. return value;
  1941. }
  1942. if (isArray(value)) {
  1943. // Recursively convert values (susceptible to call stack limits).
  1944. return arrayMap(value, baseToString) + "";
  1945. }
  1946. if (isSymbol(value)) {
  1947. return symbolToString ? symbolToString.call(value) : "";
  1948. }
  1949. var result = value + "";
  1950. return result == "0" && 1 / value == -INFINITY ? "-0" : result;
  1951. }
  1952. /**
  1953. * The base implementation of `_.uniqBy` without support for iteratee shorthands.
  1954. *
  1955. * @private
  1956. * @param {Array} array The array to inspect.
  1957. * @param {Function} [iteratee] The iteratee invoked per element.
  1958. * @param {Function} [comparator] The comparator invoked per element.
  1959. * @returns {Array} Returns the new duplicate free array.
  1960. */
  1961. function baseUniq(array, iteratee, comparator) {
  1962. var index = -1, includes = arrayIncludes, length = array.length, isCommon = true, result = [], seen = result;
  1963. if (comparator) {
  1964. isCommon = false;
  1965. includes = arrayIncludesWith;
  1966. }
  1967. else if (length >= LARGE_ARRAY_SIZE) {
  1968. var set = iteratee ? null : createSet(array);
  1969. if (set) {
  1970. return setToArray(set);
  1971. }
  1972. isCommon = false;
  1973. includes = cacheHas;
  1974. seen = new SetCache();
  1975. }
  1976. else {
  1977. seen = iteratee ? [] : result;
  1978. }
  1979. outer: while (++index < length) {
  1980. var value = array[index], computed = iteratee ? iteratee(value) : value;
  1981. value = comparator || value !== 0 ? value : 0;
  1982. if (isCommon && computed === computed) {
  1983. var seenIndex = seen.length;
  1984. while (seenIndex--) {
  1985. if (seen[seenIndex] === computed) {
  1986. continue outer;
  1987. }
  1988. }
  1989. if (iteratee) {
  1990. seen.push(computed);
  1991. }
  1992. result.push(value);
  1993. }
  1994. else if (!includes(seen, computed, comparator)) {
  1995. if (seen !== result) {
  1996. seen.push(computed);
  1997. }
  1998. result.push(value);
  1999. }
  2000. }
  2001. return result;
  2002. }
  2003. /**
  2004. * Casts `value` to a path array if it's not one.
  2005. *
  2006. * @private
  2007. * @param {*} value The value to inspect.
  2008. * @param {Object} [object] The object to query keys on.
  2009. * @returns {Array} Returns the cast property path array.
  2010. */
  2011. function castPath(value, object) {
  2012. if (isArray(value)) {
  2013. return value;
  2014. }
  2015. return isKey(value, object) ? [value] : stringToPath(toString(value));
  2016. }
  2017. /**
  2018. * Creates a clone of `buffer`.
  2019. *
  2020. * @private
  2021. * @param {Buffer} buffer The buffer to clone.
  2022. * @param {boolean} [isDeep] Specify a deep clone.
  2023. * @returns {Buffer} Returns the cloned buffer.
  2024. */
  2025. function cloneBuffer(buffer, isDeep) {
  2026. if (isDeep) {
  2027. return buffer.slice();
  2028. }
  2029. var length = buffer.length, result = allocUnsafe
  2030. ? allocUnsafe(length)
  2031. : new buffer.constructor(length);
  2032. buffer.copy(result);
  2033. return result;
  2034. }
  2035. /**
  2036. * Creates a clone of `arrayBuffer`.
  2037. *
  2038. * @private
  2039. * @param {ArrayBuffer} arrayBuffer The array buffer to clone.
  2040. * @returns {ArrayBuffer} Returns the cloned array buffer.
  2041. */
  2042. function cloneArrayBuffer(arrayBuffer) {
  2043. var result = new arrayBuffer.constructor(arrayBuffer.byteLength);
  2044. new Uint8Array(result).set(new Uint8Array(arrayBuffer));
  2045. return result;
  2046. }
  2047. /**
  2048. * Creates a clone of `dataView`.
  2049. *
  2050. * @private
  2051. * @param {Object} dataView The data view to clone.
  2052. * @param {boolean} [isDeep] Specify a deep clone.
  2053. * @returns {Object} Returns the cloned data view.
  2054. */
  2055. function cloneDataView(dataView, isDeep) {
  2056. var buffer = isDeep
  2057. ? cloneArrayBuffer(dataView.buffer)
  2058. : dataView.buffer;
  2059. return new dataView.constructor(buffer, dataView.byteOffset, dataView.byteLength);
  2060. }
  2061. /**
  2062. * Creates a clone of `map`.
  2063. *
  2064. * @private
  2065. * @param {Object} map The map to clone.
  2066. * @param {Function} cloneFunc The function to clone values.
  2067. * @param {boolean} [isDeep] Specify a deep clone.
  2068. * @returns {Object} Returns the cloned map.
  2069. */
  2070. function cloneMap(map, isDeep, cloneFunc) {
  2071. var array = isDeep
  2072. ? cloneFunc(mapToArray(map), CLONE_DEEP_FLAG)
  2073. : mapToArray(map);
  2074. return arrayReduce(array, addMapEntry, new map.constructor());
  2075. }
  2076. /**
  2077. * Creates a clone of `regexp`.
  2078. *
  2079. * @private
  2080. * @param {Object} regexp The regexp to clone.
  2081. * @returns {Object} Returns the cloned regexp.
  2082. */
  2083. function cloneRegExp(regexp) {
  2084. var result = new regexp.constructor(regexp.source, reFlags.exec(regexp));
  2085. result.lastIndex = regexp.lastIndex;
  2086. return result;
  2087. }
  2088. /**
  2089. * Creates a clone of `set`.
  2090. *
  2091. * @private
  2092. * @param {Object} set The set to clone.
  2093. * @param {Function} cloneFunc The function to clone values.
  2094. * @param {boolean} [isDeep] Specify a deep clone.
  2095. * @returns {Object} Returns the cloned set.
  2096. */
  2097. function cloneSet(set, isDeep, cloneFunc) {
  2098. var array = isDeep
  2099. ? cloneFunc(setToArray(set), CLONE_DEEP_FLAG)
  2100. : setToArray(set);
  2101. return arrayReduce(array, addSetEntry, new set.constructor());
  2102. }
  2103. /**
  2104. * Creates a clone of the `symbol` object.
  2105. *
  2106. * @private
  2107. * @param {Object} symbol The symbol object to clone.
  2108. * @returns {Object} Returns the cloned symbol object.
  2109. */
  2110. function cloneSymbol(symbol) {
  2111. return symbolValueOf ? Object(symbolValueOf.call(symbol)) : {};
  2112. }
  2113. /**
  2114. * Creates a clone of `typedArray`.
  2115. *
  2116. * @private
  2117. * @param {Object} typedArray The typed array to clone.
  2118. * @param {boolean} [isDeep] Specify a deep clone.
  2119. * @returns {Object} Returns the cloned typed array.
  2120. */
  2121. function cloneTypedArray(typedArray, isDeep) {
  2122. var buffer = isDeep
  2123. ? cloneArrayBuffer(typedArray.buffer)
  2124. : typedArray.buffer;
  2125. return new typedArray.constructor(buffer, typedArray.byteOffset, typedArray.length);
  2126. }
  2127. /**
  2128. * Copies the values of `source` to `array`.
  2129. *
  2130. * @private
  2131. * @param {Array} source The array to copy values from.
  2132. * @param {Array} [array=[]] The array to copy values to.
  2133. * @returns {Array} Returns `array`.
  2134. */
  2135. function copyArray(source, array) {
  2136. var index = -1, length = source.length;
  2137. array || (array = Array(length));
  2138. while (++index < length) {
  2139. array[index] = source[index];
  2140. }
  2141. return array;
  2142. }
  2143. /**
  2144. * Copies properties of `source` to `object`.
  2145. *
  2146. * @private
  2147. * @param {Object} source The object to copy properties from.
  2148. * @param {Array} props The property identifiers to copy.
  2149. * @param {Object} [object={}] The object to copy properties to.
  2150. * @param {Function} [customizer] The function to customize copied values.
  2151. * @returns {Object} Returns `object`.
  2152. */
  2153. function copyObject(source, props, object, customizer) {
  2154. var isNew = !object;
  2155. object || (object = {});
  2156. var index = -1, length = props.length;
  2157. while (++index < length) {
  2158. var key = props[index];
  2159. var newValue = customizer
  2160. ? customizer(object[key], source[key], key, object, source)
  2161. : undefined;
  2162. if (newValue === undefined) {
  2163. newValue = source[key];
  2164. }
  2165. if (isNew) {
  2166. baseAssignValue(object, key, newValue);
  2167. }
  2168. else {
  2169. assignValue(object, key, newValue);
  2170. }
  2171. }
  2172. return object;
  2173. }
  2174. /**
  2175. * Copies own symbols of `source` to `object`.
  2176. *
  2177. * @private
  2178. * @param {Object} source The object to copy symbols from.
  2179. * @param {Object} [object={}] The object to copy symbols to.
  2180. * @returns {Object} Returns `object`.
  2181. */
  2182. function copySymbols(source, object) {
  2183. return copyObject(source, getSymbols(source), object);
  2184. }
  2185. /**
  2186. * Copies own and inherited symbols of `source` to `object`.
  2187. *
  2188. * @private
  2189. * @param {Object} source The object to copy symbols from.
  2190. * @param {Object} [object={}] The object to copy symbols to.
  2191. * @returns {Object} Returns `object`.
  2192. */
  2193. function copySymbolsIn(source, object) {
  2194. return copyObject(source, getSymbolsIn(source), object);
  2195. }
  2196. /**
  2197. * Creates a function like `_.assign`.
  2198. *
  2199. * @private
  2200. * @param {Function} assigner The function to assign values.
  2201. * @returns {Function} Returns the new assigner function.
  2202. */
  2203. function createAssigner(assigner) {
  2204. return baseRest(function (object, sources) {
  2205. var index = -1, length = sources.length, customizer = length > 1 ? sources[length - 1] : undefined, guard = length > 2 ? sources[2] : undefined;
  2206. customizer =
  2207. assigner.length > 3 && typeof customizer == "function"
  2208. ? (length--, customizer)
  2209. : undefined;
  2210. if (guard && isIterateeCall(sources[0], sources[1], guard)) {
  2211. customizer = length < 3 ? undefined : customizer;
  2212. length = 1;
  2213. }
  2214. object = Object(object);
  2215. while (++index < length) {
  2216. var source = sources[index];
  2217. if (source) {
  2218. assigner(object, source, index, customizer);
  2219. }
  2220. }
  2221. return object;
  2222. });
  2223. }
  2224. /**
  2225. * Creates a `baseEach` or `baseEachRight` function.
  2226. *
  2227. * @private
  2228. * @param {Function} eachFunc The function to iterate over a collection.
  2229. * @param {boolean} [fromRight] Specify iterating from right to left.
  2230. * @returns {Function} Returns the new base function.
  2231. */
  2232. function createBaseEach(eachFunc, fromRight) {
  2233. return function (collection, iteratee) {
  2234. if (collection == null) {
  2235. return collection;
  2236. }
  2237. if (!isArrayLike(collection)) {
  2238. return eachFunc(collection, iteratee);
  2239. }
  2240. var length = collection.length, index = fromRight ? length : -1, iterable = Object(collection);
  2241. while (fromRight ? index-- : ++index < length) {
  2242. if (iteratee(iterable[index], index, iterable) === false) {
  2243. break;
  2244. }
  2245. }
  2246. return collection;
  2247. };
  2248. }
  2249. /**
  2250. * Creates a base function for methods like `_.forIn` and `_.forOwn`.
  2251. *
  2252. * @private
  2253. * @param {boolean} [fromRight] Specify iterating from right to left.
  2254. * @returns {Function} Returns the new base function.
  2255. */
  2256. function createBaseFor(fromRight) {
  2257. return function (object, iteratee, keysFunc) {
  2258. var index = -1, iterable = Object(object), props = keysFunc(object), length = props.length;
  2259. while (length--) {
  2260. var key = props[fromRight ? length : ++index];
  2261. if (iteratee(iterable[key], key, iterable) === false) {
  2262. break;
  2263. }
  2264. }
  2265. return object;
  2266. };
  2267. }
  2268. /**
  2269. * Creates a set object of `values`.
  2270. *
  2271. * @private
  2272. * @param {Array} values The values to add to the set.
  2273. * @returns {Object} Returns the new set.
  2274. */
  2275. var createSet = !(Set && 1 / setToArray(new Set([, -0]))[1] == INFINITY)
  2276. ? noop
  2277. : function (values) {
  2278. return new Set(values);
  2279. };
  2280. /**
  2281. * A specialized version of `baseIsEqualDeep` for arrays with support for
  2282. * partial deep comparisons.
  2283. *
  2284. * @private
  2285. * @param {Array} array The array to compare.
  2286. * @param {Array} other The other array to compare.
  2287. * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.
  2288. * @param {Function} customizer The function to customize comparisons.
  2289. * @param {Function} equalFunc The function to determine equivalents of values.
  2290. * @param {Object} stack Tracks traversed `array` and `other` objects.
  2291. * @returns {boolean} Returns `true` if the arrays are equivalent, else `false`.
  2292. */
  2293. function equalArrays(array, other, bitmask, customizer, equalFunc, stack) {
  2294. var isPartial = bitmask & COMPARE_PARTIAL_FLAG, arrLength = array.length, othLength = other.length;
  2295. if (arrLength != othLength && !(isPartial && othLength > arrLength)) {
  2296. return false;
  2297. }
  2298. // Assume cyclic values are equal.
  2299. var stacked = stack.get(array);
  2300. if (stacked && stack.get(other)) {
  2301. return stacked == other;
  2302. }
  2303. var index = -1, result = true, seen = bitmask & COMPARE_UNORDERED_FLAG ? new SetCache() : undefined;
  2304. stack.set(array, other);
  2305. stack.set(other, array);
  2306. // Ignore non-index properties.
  2307. while (++index < arrLength) {
  2308. var arrValue = array[index], othValue = other[index];
  2309. if (customizer) {
  2310. var compared = isPartial
  2311. ? customizer(othValue, arrValue, index, other, array, stack)
  2312. : customizer(arrValue, othValue, index, array, other, stack);
  2313. }
  2314. if (compared !== undefined) {
  2315. if (compared) {
  2316. continue;
  2317. }
  2318. result = false;
  2319. break;
  2320. }
  2321. // Recursively compare arrays (susceptible to call stack limits).
  2322. if (seen) {
  2323. if (!arraySome(other, function (othValue, othIndex) {
  2324. if (!cacheHas(seen, othIndex) &&
  2325. (arrValue === othValue ||
  2326. equalFunc(arrValue, othValue, bitmask, customizer, stack))) {
  2327. return seen.push(othIndex);
  2328. }
  2329. })) {
  2330. result = false;
  2331. break;
  2332. }
  2333. }
  2334. else if (!(arrValue === othValue ||
  2335. equalFunc(arrValue, othValue, bitmask, customizer, stack))) {
  2336. result = false;
  2337. break;
  2338. }
  2339. }
  2340. stack["delete"](array);
  2341. stack["delete"](other);
  2342. return result;
  2343. }
  2344. /**
  2345. * A specialized version of `baseIsEqualDeep` for comparing objects of
  2346. * the same `toStringTag`.
  2347. *
  2348. * **Note:** This function only supports comparing values with tags of
  2349. * `Boolean`, `Date`, `Error`, `Number`, `RegExp`, or `String`.
  2350. *
  2351. * @private
  2352. * @param {Object} object The object to compare.
  2353. * @param {Object} other The other object to compare.
  2354. * @param {string} tag The `toStringTag` of the objects to compare.
  2355. * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.
  2356. * @param {Function} customizer The function to customize comparisons.
  2357. * @param {Function} equalFunc The function to determine equivalents of values.
  2358. * @param {Object} stack Tracks traversed `object` and `other` objects.
  2359. * @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
  2360. */
  2361. function equalByTag(object, other, tag, bitmask, customizer, equalFunc, stack) {
  2362. switch (tag) {
  2363. case dataViewTag:
  2364. if (object.byteLength != other.byteLength ||
  2365. object.byteOffset != other.byteOffset) {
  2366. return false;
  2367. }
  2368. object = object.buffer;
  2369. other = other.buffer;
  2370. case arrayBufferTag:
  2371. if (object.byteLength != other.byteLength ||
  2372. !equalFunc(new Uint8Array(object), new Uint8Array(other))) {
  2373. return false;
  2374. }
  2375. return true;
  2376. case boolTag:
  2377. case dateTag:
  2378. case numberTag:
  2379. // Coerce booleans to `1` or `0` and dates to milliseconds.
  2380. // Invalid dates are coerced to `NaN`.
  2381. return eq(+object, +other);
  2382. case errorTag:
  2383. return (object.name == other.name && object.message == other.message);
  2384. case regexpTag:
  2385. case stringTag:
  2386. // Coerce regexes to strings and treat strings, primitives and objects,
  2387. // as equal. See http://www.ecma-international.org/ecma-262/7.0/#sec-regexp.prototype.tostring
  2388. // for more details.
  2389. return object == other + "";
  2390. case mapTag:
  2391. var convert = mapToArray;
  2392. case setTag:
  2393. var isPartial = bitmask & COMPARE_PARTIAL_FLAG;
  2394. convert || (convert = setToArray);
  2395. if (object.size != other.size && !isPartial) {
  2396. return false;
  2397. }
  2398. // Assume cyclic values are equal.
  2399. var stacked = stack.get(object);
  2400. if (stacked) {
  2401. return stacked == other;
  2402. }
  2403. bitmask |= COMPARE_UNORDERED_FLAG;
  2404. // Recursively compare objects (susceptible to call stack limits).
  2405. stack.set(object, other);
  2406. var result = equalArrays(convert(object), convert(other), bitmask, customizer, equalFunc, stack);
  2407. stack["delete"](object);
  2408. return result;
  2409. case symbolTag:
  2410. if (symbolValueOf) {
  2411. return (symbolValueOf.call(object) == symbolValueOf.call(other));
  2412. }
  2413. }
  2414. return false;
  2415. }
  2416. /**
  2417. * A specialized version of `baseIsEqualDeep` for objects with support for
  2418. * partial deep comparisons.
  2419. *
  2420. * @private
  2421. * @param {Object} object The object to compare.
  2422. * @param {Object} other The other object to compare.
  2423. * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.
  2424. * @param {Function} customizer The function to customize comparisons.
  2425. * @param {Function} equalFunc The function to determine equivalents of values.
  2426. * @param {Object} stack Tracks traversed `object` and `other` objects.
  2427. * @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
  2428. */
  2429. function equalObjects(object, other, bitmask, customizer, equalFunc, stack) {
  2430. var isPartial = bitmask & COMPARE_PARTIAL_FLAG, objProps = getAllKeys(object), objLength = objProps.length, othProps = getAllKeys(other), othLength = othProps.length;
  2431. if (objLength != othLength && !isPartial) {
  2432. return false;
  2433. }
  2434. var index = objLength;
  2435. while (index--) {
  2436. var key = objProps[index];
  2437. if (!(isPartial ? key in other : hasOwnProperty.call(other, key))) {
  2438. return false;
  2439. }
  2440. }
  2441. // Assume cyclic values are equal.
  2442. var stacked = stack.get(object);
  2443. if (stacked && stack.get(other)) {
  2444. return stacked == other;
  2445. }
  2446. var result = true;
  2447. stack.set(object, other);
  2448. stack.set(other, object);
  2449. var skipCtor = isPartial;
  2450. while (++index < objLength) {
  2451. key = objProps[index];
  2452. var objValue = object[key], othValue = other[key];
  2453. if (customizer) {
  2454. var compared = isPartial
  2455. ? customizer(othValue, objValue, key, other, object, stack)
  2456. : customizer(objValue, othValue, key, object, other, stack);
  2457. }
  2458. // Recursively compare objects (susceptible to call stack limits).
  2459. if (!(compared === undefined
  2460. ? objValue === othValue ||
  2461. equalFunc(objValue, othValue, bitmask, customizer, stack)
  2462. : compared)) {
  2463. result = false;
  2464. break;
  2465. }
  2466. skipCtor || (skipCtor = key == "constructor");
  2467. }
  2468. if (result && !skipCtor) {
  2469. var objCtor = object.constructor, othCtor = other.constructor;
  2470. // Non `Object` object instances with different constructors are not equal.
  2471. if (objCtor != othCtor &&
  2472. ("constructor" in object && "constructor" in other) &&
  2473. !(typeof objCtor == "function" &&
  2474. objCtor instanceof objCtor &&
  2475. typeof othCtor == "function" &&
  2476. othCtor instanceof othCtor)) {
  2477. result = false;
  2478. }
  2479. }
  2480. stack["delete"](object);
  2481. stack["delete"](other);
  2482. return result;
  2483. }
  2484. /**
  2485. * Creates an array of own enumerable property names and symbols of `object`.
  2486. *
  2487. * @private
  2488. * @param {Object} object The object to query.
  2489. * @returns {Array} Returns the array of property names and symbols.
  2490. */
  2491. function getAllKeys(object) {
  2492. return baseGetAllKeys(object, keys, getSymbols);
  2493. }
  2494. /**
  2495. * Creates an array of own and inherited enumerable property names and
  2496. * symbols of `object`.
  2497. *
  2498. * @private
  2499. * @param {Object} object The object to query.
  2500. * @returns {Array} Returns the array of property names and symbols.
  2501. */
  2502. function getAllKeysIn(object) {
  2503. return baseGetAllKeys(object, keysIn, getSymbolsIn);
  2504. }
  2505. /**
  2506. * Gets the appropriate "iteratee" function. If `_.iteratee` is customized,
  2507. * this function returns the custom method, otherwise it returns `baseIteratee`.
  2508. * If arguments are provided, the chosen function is invoked with them and
  2509. * its result is returned.
  2510. *
  2511. * @private
  2512. * @param {*} [value] The value to convert to an iteratee.
  2513. * @param {number} [arity] The arity of the created iteratee.
  2514. * @returns {Function} Returns the chosen function or its result.
  2515. */
  2516. function getIteratee() {
  2517. var result = lodash.iteratee || iteratee;
  2518. result = result === iteratee ? baseIteratee : result;
  2519. return arguments.length ? result(arguments[0], arguments[1]) : result;
  2520. }
  2521. /**
  2522. * Gets the data for `map`.
  2523. *
  2524. * @private
  2525. * @param {Object} map The map to query.
  2526. * @param {string} key The reference key.
  2527. * @returns {*} Returns the map data.
  2528. */
  2529. function getMapData(map, key) {
  2530. var data = map.__data__;
  2531. return isKeyable(key)
  2532. ? data[typeof key == "string" ? "string" : "hash"]
  2533. : data.map;
  2534. }
  2535. /**
  2536. * Gets the property names, values, and compare flags of `object`.
  2537. *
  2538. * @private
  2539. * @param {Object} object The object to query.
  2540. * @returns {Array} Returns the match data of `object`.
  2541. */
  2542. function getMatchData(object) {
  2543. var result = keys(object), length = result.length;
  2544. while (length--) {
  2545. var key = result[length], value = object[key];
  2546. result[length] = [key, value, isStrictComparable(value)];
  2547. }
  2548. return result;
  2549. }
  2550. /**
  2551. * Gets the native function at `key` of `object`.
  2552. *
  2553. * @private
  2554. * @param {Object} object The object to query.
  2555. * @param {string} key The key of the method to get.
  2556. * @returns {*} Returns the function if it's native, else `undefined`.
  2557. */
  2558. function getNative(object, key) {
  2559. var value = getValue(object, key);
  2560. return baseIsNative(value) ? value : undefined;
  2561. }
  2562. /**
  2563. * A specialized version of `baseGetTag` which ignores `Symbol.toStringTag` values.
  2564. *
  2565. * @private
  2566. * @param {*} value The value to query.
  2567. * @returns {string} Returns the raw `toStringTag`.
  2568. */
  2569. function getRawTag(value) {
  2570. var isOwn = hasOwnProperty.call(value, symToStringTag), tag = value[symToStringTag];
  2571. try {
  2572. value[symToStringTag] = undefined;
  2573. var unmasked = true;
  2574. }
  2575. catch (e) { }
  2576. var result = nativeObjectToString.call(value);
  2577. if (unmasked) {
  2578. if (isOwn) {
  2579. value[symToStringTag] = tag;
  2580. }
  2581. else {
  2582. delete value[symToStringTag];
  2583. }
  2584. }
  2585. return result;
  2586. }
  2587. /**
  2588. * Creates an array of the own enumerable symbols of `object`.
  2589. *
  2590. * @private
  2591. * @param {Object} object The object to query.
  2592. * @returns {Array} Returns the array of symbols.
  2593. */
  2594. var getSymbols = !nativeGetSymbols
  2595. ? stubArray
  2596. : function (object) {
  2597. if (object == null) {
  2598. return [];
  2599. }
  2600. object = Object(object);
  2601. return arrayFilter(nativeGetSymbols(object), function (symbol) {
  2602. return propertyIsEnumerable.call(object, symbol);
  2603. });
  2604. };
  2605. /**
  2606. * Creates an array of the own and inherited enumerable symbols of `object`.
  2607. *
  2608. * @private
  2609. * @param {Object} object The object to query.
  2610. * @returns {Array} Returns the array of symbols.
  2611. */
  2612. var getSymbolsIn = !nativeGetSymbols
  2613. ? stubArray
  2614. : function (object) {
  2615. var result = [];
  2616. while (object) {
  2617. arrayPush(result, getSymbols(object));
  2618. object = getPrototype(object);
  2619. }
  2620. return result;
  2621. };
  2622. /**
  2623. * Gets the `toStringTag` of `value`.
  2624. *
  2625. * @private
  2626. * @param {*} value The value to query.
  2627. * @returns {string} Returns the `toStringTag`.
  2628. */
  2629. var getTag = baseGetTag;
  2630. // Fallback for data views, maps, sets, and weak maps in IE 11 and promises in Node.js < 6.
  2631. if ((DataView && getTag(new DataView(new ArrayBuffer(1))) != dataViewTag) ||
  2632. (Map && getTag(new Map()) != mapTag) ||
  2633. (Promise && getTag(Promise.resolve()) != promiseTag) ||
  2634. (Set && getTag(new Set()) != setTag) ||
  2635. (WeakMap && getTag(new WeakMap()) != weakMapTag)) {
  2636. getTag = function (value) {
  2637. var result = baseGetTag(value), Ctor = result == objectTag ? value.constructor : undefined, ctorString = Ctor ? toSource(Ctor) : "";
  2638. if (ctorString) {
  2639. switch (ctorString) {
  2640. case dataViewCtorString:
  2641. return dataViewTag;
  2642. case mapCtorString:
  2643. return mapTag;
  2644. case promiseCtorString:
  2645. return promiseTag;
  2646. case setCtorString:
  2647. return setTag;
  2648. case weakMapCtorString:
  2649. return weakMapTag;
  2650. }
  2651. }
  2652. return result;
  2653. };
  2654. }
  2655. /**
  2656. * Checks if `path` exists on `object`.
  2657. *
  2658. * @private
  2659. * @param {Object} object The object to query.
  2660. * @param {Array|string} path The path to check.
  2661. * @param {Function} hasFunc The function to check properties.
  2662. * @returns {boolean} Returns `true` if `path` exists, else `false`.
  2663. */
  2664. function hasPath(object, path, hasFunc) {
  2665. path = castPath(path, object);
  2666. var index = -1, length = path.length, result = false;
  2667. while (++index < length) {
  2668. var key = toKey(path[index]);
  2669. if (!(result = object != null && hasFunc(object, key))) {
  2670. break;
  2671. }
  2672. object = object[key];
  2673. }
  2674. if (result || ++index != length) {
  2675. return result;
  2676. }
  2677. length = object == null ? 0 : object.length;
  2678. return (!!length &&
  2679. isLength(length) &&
  2680. isIndex(key, length) &&
  2681. (isArray(object) || isArguments(object)));
  2682. }
  2683. /**
  2684. * Initializes an array clone.
  2685. *
  2686. * @private
  2687. * @param {Array} array The array to clone.
  2688. * @returns {Array} Returns the initialized clone.
  2689. */
  2690. function initCloneArray(array) {
  2691. var length = array.length, result = array.constructor(length);
  2692. // Add properties assigned by `RegExp#exec`.
  2693. if (length &&
  2694. typeof array[0] == "string" &&
  2695. hasOwnProperty.call(array, "index")) {
  2696. result.index = array.index;
  2697. result.input = array.input;
  2698. }
  2699. return result;
  2700. }
  2701. /**
  2702. * Initializes an object clone.
  2703. *
  2704. * @private
  2705. * @param {Object} object The object to clone.
  2706. * @returns {Object} Returns the initialized clone.
  2707. */
  2708. function initCloneObject(object) {
  2709. return typeof object.constructor == "function" && !isPrototype(object)
  2710. ? baseCreate(getPrototype(object))
  2711. : {};
  2712. }
  2713. /**
  2714. * Initializes an object clone based on its `toStringTag`.
  2715. *
  2716. * **Note:** This function only supports cloning values with tags of
  2717. * `Boolean`, `Date`, `Error`, `Number`, `RegExp`, or `String`.
  2718. *
  2719. * @private
  2720. * @param {Object} object The object to clone.
  2721. * @param {string} tag The `toStringTag` of the object to clone.
  2722. * @param {Function} cloneFunc The function to clone values.
  2723. * @param {boolean} [isDeep] Specify a deep clone.
  2724. * @returns {Object} Returns the initialized clone.
  2725. */
  2726. function initCloneByTag(object, tag, cloneFunc, isDeep) {
  2727. var Ctor = object.constructor;
  2728. switch (tag) {
  2729. case arrayBufferTag:
  2730. return cloneArrayBuffer(object);
  2731. case boolTag:
  2732. case dateTag:
  2733. return new Ctor(+object);
  2734. case dataViewTag:
  2735. return cloneDataView(object, isDeep);
  2736. case float32Tag:
  2737. case float64Tag:
  2738. case int8Tag:
  2739. case int16Tag:
  2740. case int32Tag:
  2741. case uint8Tag:
  2742. case uint8ClampedTag:
  2743. case uint16Tag:
  2744. case uint32Tag:
  2745. return cloneTypedArray(object, isDeep);
  2746. case mapTag:
  2747. return cloneMap(object, isDeep, cloneFunc);
  2748. case numberTag:
  2749. case stringTag:
  2750. return new Ctor(object);
  2751. case regexpTag:
  2752. return cloneRegExp(object);
  2753. case setTag:
  2754. return cloneSet(object, isDeep, cloneFunc);
  2755. case symbolTag:
  2756. return cloneSymbol(object);
  2757. }
  2758. }
  2759. /**
  2760. * Checks if `value` is a flattenable `arguments` object or array.
  2761. *
  2762. * @private
  2763. * @param {*} value The value to check.
  2764. * @returns {boolean} Returns `true` if `value` is flattenable, else `false`.
  2765. */
  2766. function isFlattenable(value) {
  2767. return (isArray(value) ||
  2768. isArguments(value) ||
  2769. !!(spreadableSymbol && value && value[spreadableSymbol]));
  2770. }
  2771. /**
  2772. * Checks if `value` is a valid array-like index.
  2773. *
  2774. * @private
  2775. * @param {*} value The value to check.
  2776. * @param {number} [length=MAX_SAFE_INTEGER] The upper bounds of a valid index.
  2777. * @returns {boolean} Returns `true` if `value` is a valid index, else `false`.
  2778. */
  2779. function isIndex(value, length) {
  2780. length = length == null ? MAX_SAFE_INTEGER : length;
  2781. return (!!length &&
  2782. (typeof value == "number" || reIsUint.test(value)) &&
  2783. (value > -1 && value % 1 == 0 && value < length));
  2784. }
  2785. /**
  2786. * Checks if the given arguments are from an iteratee call.
  2787. *
  2788. * @private
  2789. * @param {*} value The potential iteratee value argument.
  2790. * @param {*} index The potential iteratee index or key argument.
  2791. * @param {*} object The potential iteratee object argument.
  2792. * @returns {boolean} Returns `true` if the arguments are from an iteratee call,
  2793. * else `false`.
  2794. */
  2795. function isIterateeCall(value, index, object) {
  2796. if (!isObject(object)) {
  2797. return false;
  2798. }
  2799. var type = typeof index;
  2800. if (type == "number"
  2801. ? isArrayLike(object) && isIndex(index, object.length)
  2802. : type == "string" && index in object) {
  2803. return eq(object[index], value);
  2804. }
  2805. return false;
  2806. }
  2807. /**
  2808. * Checks if `value` is a property name and not a property path.
  2809. *
  2810. * @private
  2811. * @param {*} value The value to check.
  2812. * @param {Object} [object] The object to query keys on.
  2813. * @returns {boolean} Returns `true` if `value` is a property name, else `false`.
  2814. */
  2815. function isKey(value, object) {
  2816. if (isArray(value)) {
  2817. return false;
  2818. }
  2819. var type = typeof value;
  2820. if (type == "number" ||
  2821. type == "symbol" ||
  2822. type == "boolean" ||
  2823. value == null ||
  2824. isSymbol(value)) {
  2825. return true;
  2826. }
  2827. return (reIsPlainProp.test(value) ||
  2828. !reIsDeepProp.test(value) ||
  2829. (object != null && value in Object(object)));
  2830. }
  2831. /**
  2832. * Checks if `value` is suitable for use as unique object key.
  2833. *
  2834. * @private
  2835. * @param {*} value The value to check.
  2836. * @returns {boolean} Returns `true` if `value` is suitable, else `false`.
  2837. */
  2838. function isKeyable(value) {
  2839. var type = typeof value;
  2840. return type == "string" ||
  2841. type == "number" ||
  2842. type == "symbol" ||
  2843. type == "boolean"
  2844. ? value !== "__proto__"
  2845. : value === null;
  2846. }
  2847. /**
  2848. * Checks if `func` has its source masked.
  2849. *
  2850. * @private
  2851. * @param {Function} func The function to check.
  2852. * @returns {boolean} Returns `true` if `func` is masked, else `false`.
  2853. */
  2854. function isMasked(func) {
  2855. return !!maskSrcKey && maskSrcKey in func;
  2856. }
  2857. /**
  2858. * Checks if `value` is likely a prototype object.
  2859. *
  2860. * @private
  2861. * @param {*} value The value to check.
  2862. * @returns {boolean} Returns `true` if `value` is a prototype, else `false`.
  2863. */
  2864. function isPrototype(value) {
  2865. var Ctor = value && value.constructor, proto = (typeof Ctor == "function" && Ctor.prototype) || objectProto;
  2866. return value === proto;
  2867. }
  2868. /**
  2869. * Checks if `value` is suitable for strict equality comparisons, i.e. `===`.
  2870. *
  2871. * @private
  2872. * @param {*} value The value to check.
  2873. * @returns {boolean} Returns `true` if `value` if suitable for strict
  2874. * equality comparisons, else `false`.
  2875. */
  2876. function isStrictComparable(value) {
  2877. return value === value && !isObject(value);
  2878. }
  2879. /**
  2880. * A specialized version of `matchesProperty` for source values suitable
  2881. * for strict equality comparisons, i.e. `===`.
  2882. *
  2883. * @private
  2884. * @param {string} key The key of the property to get.
  2885. * @param {*} srcValue The value to match.
  2886. * @returns {Function} Returns the new spec function.
  2887. */
  2888. function matchesStrictComparable(key, srcValue) {
  2889. return function (object) {
  2890. if (object == null) {
  2891. return false;
  2892. }
  2893. return (object[key] === srcValue &&
  2894. (srcValue !== undefined || key in Object(object)));
  2895. };
  2896. }
  2897. /**
  2898. * A specialized version of `_.memoize` which clears the memoized function's
  2899. * cache when it exceeds `MAX_MEMOIZE_SIZE`.
  2900. *
  2901. * @private
  2902. * @param {Function} func The function to have its output memoized.
  2903. * @returns {Function} Returns the new memoized function.
  2904. */
  2905. function memoizeCapped(func) {
  2906. var result = memoize(func, function (key) {
  2907. if (cache.size === MAX_MEMOIZE_SIZE) {
  2908. cache.clear();
  2909. }
  2910. return key;
  2911. });
  2912. var cache = result.cache;
  2913. return result;
  2914. }
  2915. /**
  2916. * This function is like
  2917. * [`Object.keys`](http://ecma-international.org/ecma-262/7.0/#sec-object.keys)
  2918. * except that it includes inherited enumerable properties.
  2919. *
  2920. * @private
  2921. * @param {Object} object The object to query.
  2922. * @returns {Array} Returns the array of property names.
  2923. */
  2924. function nativeKeysIn(object) {
  2925. var result = [];
  2926. if (object != null) {
  2927. for (var key in Object(object)) {
  2928. result.push(key);
  2929. }
  2930. }
  2931. return result;
  2932. }
  2933. /**
  2934. * Converts `value` to a string using `Object.prototype.toString`.
  2935. *
  2936. * @private
  2937. * @param {*} value The value to convert.
  2938. * @returns {string} Returns the converted string.
  2939. */
  2940. function objectToString(value) {
  2941. return nativeObjectToString.call(value);
  2942. }
  2943. /**
  2944. * A specialized version of `baseRest` which transforms the rest array.
  2945. *
  2946. * @private
  2947. * @param {Function} func The function to apply a rest parameter to.
  2948. * @param {number} [start=func.length-1] The start position of the rest parameter.
  2949. * @param {Function} transform The rest array transform.
  2950. * @returns {Function} Returns the new function.
  2951. */
  2952. function overRest(func, start, transform) {
  2953. start = nativeMax(start === undefined ? func.length - 1 : start, 0);
  2954. return function () {
  2955. var args = arguments, index = -1, length = nativeMax(args.length - start, 0), array = Array(length);
  2956. while (++index < length) {
  2957. array[index] = args[start + index];
  2958. }
  2959. index = -1;
  2960. var otherArgs = Array(start + 1);
  2961. while (++index < start) {
  2962. otherArgs[index] = args[index];
  2963. }
  2964. otherArgs[start] = transform(array);
  2965. return apply(func, this, otherArgs);
  2966. };
  2967. }
  2968. /**
  2969. * Sets the `toString` method of `func` to return `string`.
  2970. *
  2971. * @private
  2972. * @param {Function} func The function to modify.
  2973. * @param {Function} string The `toString` result.
  2974. * @returns {Function} Returns `func`.
  2975. */
  2976. var setToString = shortOut(baseSetToString);
  2977. /**
  2978. * Creates a function that'll short out and invoke `identity` instead
  2979. * of `func` when it's called `HOT_COUNT` or more times in `HOT_SPAN`
  2980. * milliseconds.
  2981. *
  2982. * @private
  2983. * @param {Function} func The function to restrict.
  2984. * @returns {Function} Returns the new shortable function.
  2985. */
  2986. function shortOut(func) {
  2987. var count = 0, lastCalled = 0;
  2988. return function () {
  2989. var stamp = nativeNow(), remaining = HOT_SPAN - (stamp - lastCalled);
  2990. lastCalled = stamp;
  2991. if (remaining > 0) {
  2992. if (++count >= HOT_COUNT) {
  2993. return arguments[0];
  2994. }
  2995. }
  2996. else {
  2997. count = 0;
  2998. }
  2999. return func.apply(undefined, arguments);
  3000. };
  3001. }
  3002. /**
  3003. * Converts `string` to a property path array.
  3004. *
  3005. * @private
  3006. * @param {string} string The string to convert.
  3007. * @returns {Array} Returns the property path array.
  3008. */
  3009. var stringToPath = memoizeCapped(function (string) {
  3010. var result = [];
  3011. if (reLeadingDot.test(string)) {
  3012. result.push("");
  3013. }
  3014. string.replace(rePropName, function (match, number, quote, string) {
  3015. result.push(quote ? string.replace(reEscapeChar, "$1") : number || match);
  3016. });
  3017. return result;
  3018. });
  3019. /**
  3020. * Converts `value` to a string key if it's not a string or symbol.
  3021. *
  3022. * @private
  3023. * @param {*} value The value to inspect.
  3024. * @returns {string|symbol} Returns the key.
  3025. */
  3026. function toKey(value) {
  3027. if (typeof value == "string" || isSymbol(value)) {
  3028. return value;
  3029. }
  3030. var result = value + "";
  3031. return result == "0" && 1 / value == -INFINITY ? "-0" : result;
  3032. }
  3033. /**
  3034. * Converts `func` to its source code.
  3035. *
  3036. * @private
  3037. * @param {Function} func The function to convert.
  3038. * @returns {string} Returns the source code.
  3039. */
  3040. function toSource(func) {
  3041. if (func != null) {
  3042. try {
  3043. return funcToString.call(func);
  3044. }
  3045. catch (e) { }
  3046. try {
  3047. return func + "";
  3048. }
  3049. catch (e) { }
  3050. }
  3051. return "";
  3052. }
  3053. /*------------------------------------------------------------------------*/
  3054. /**
  3055. * Creates an array of unique values, in order, from all given arrays using
  3056. * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
  3057. * for equality comparisons.
  3058. *
  3059. * @static
  3060. * @memberOf _
  3061. * @since 0.1.0
  3062. * @category Array
  3063. * @param {...Array} [arrays] The arrays to inspect.
  3064. * @returns {Array} Returns the new array of combined values.
  3065. * @example
  3066. *
  3067. * _.union([2], [1, 2]);
  3068. * // => [2, 1]
  3069. */
  3070. var union = baseRest(function (arrays) {
  3071. return baseUniq(baseFlatten(arrays, 1, isArrayLikeObject, true));
  3072. });
  3073. /*------------------------------------------------------------------------*/
  3074. /**
  3075. * Iterates over elements of `collection` and invokes `iteratee` for each element.
  3076. * The iteratee is invoked with three arguments: (value, index|key, collection).
  3077. * Iteratee functions may exit iteration early by explicitly returning `false`.
  3078. *
  3079. * **Note:** As with other "Collections" methods, objects with a "length"
  3080. * property are iterated like arrays. To avoid this behavior use `_.forIn`
  3081. * or `_.forOwn` for object iteration.
  3082. *
  3083. * @static
  3084. * @memberOf _
  3085. * @since 0.1.0
  3086. * @alias each
  3087. * @category Collection
  3088. * @param {Array|Object} collection The collection to iterate over.
  3089. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  3090. * @returns {Array|Object} Returns `collection`.
  3091. * @see _.forEachRight
  3092. * @example
  3093. *
  3094. * _.forEach([1, 2], function(value) {
  3095. * console.log(value);
  3096. * });
  3097. * // => Logs `1` then `2`.
  3098. *
  3099. * _.forEach({ 'a': 1, 'b': 2 }, function(value, key) {
  3100. * console.log(key);
  3101. * });
  3102. * // => Logs 'a' then 'b' (iteration order is not guaranteed).
  3103. */
  3104. function forEach(collection, iteratee) {
  3105. var func = isArray(collection) ? arrayEach : baseEach;
  3106. return func(collection, getIteratee(iteratee, 3));
  3107. }
  3108. /**
  3109. * Checks if `value` is in `collection`. If `collection` is a string, it's
  3110. * checked for a substring of `value`, otherwise
  3111. * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
  3112. * is used for equality comparisons. If `fromIndex` is negative, it's used as
  3113. * the offset from the end of `collection`.
  3114. *
  3115. * @static
  3116. * @memberOf _
  3117. * @since 0.1.0
  3118. * @category Collection
  3119. * @param {Array|Object|string} collection The collection to inspect.
  3120. * @param {*} value The value to search for.
  3121. * @param {number} [fromIndex=0] The index to search from.
  3122. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.reduce`.
  3123. * @returns {boolean} Returns `true` if `value` is found, else `false`.
  3124. * @example
  3125. *
  3126. * _.includes([1, 2, 3], 1);
  3127. * // => true
  3128. *
  3129. * _.includes([1, 2, 3], 1, 2);
  3130. * // => false
  3131. *
  3132. * _.includes({ 'a': 1, 'b': 2 }, 1);
  3133. * // => true
  3134. *
  3135. * _.includes('abcd', 'bc');
  3136. * // => true
  3137. */
  3138. function includes(collection, value, fromIndex, guard) {
  3139. collection = isArrayLike(collection) ? collection : values(collection);
  3140. fromIndex = fromIndex && !guard ? toInteger(fromIndex) : 0;
  3141. var length = collection.length;
  3142. if (fromIndex < 0) {
  3143. fromIndex = nativeMax(length + fromIndex, 0);
  3144. }
  3145. return isString(collection)
  3146. ? fromIndex <= length && collection.indexOf(value, fromIndex) > -1
  3147. : !!length && baseIndexOf(collection, value, fromIndex) > -1;
  3148. }
  3149. /*------------------------------------------------------------------------*/
  3150. /**
  3151. * Creates a function that memoizes the result of `func`. If `resolver` is
  3152. * provided, it determines the cache key for storing the result based on the
  3153. * arguments provided to the memoized function. By default, the first argument
  3154. * provided to the memoized function is used as the map cache key. The `func`
  3155. * is invoked with the `this` binding of the memoized function.
  3156. *
  3157. * **Note:** The cache is exposed as the `cache` property on the memoized
  3158. * function. Its creation may be customized by replacing the `_.memoize.Cache`
  3159. * constructor with one whose instances implement the
  3160. * [`Map`](http://ecma-international.org/ecma-262/7.0/#sec-properties-of-the-map-prototype-object)
  3161. * method interface of `clear`, `delete`, `get`, `has`, and `set`.
  3162. *
  3163. * @static
  3164. * @memberOf _
  3165. * @since 0.1.0
  3166. * @category Function
  3167. * @param {Function} func The function to have its output memoized.
  3168. * @param {Function} [resolver] The function to resolve the cache key.
  3169. * @returns {Function} Returns the new memoized function.
  3170. * @example
  3171. *
  3172. * var object = { 'a': 1, 'b': 2 };
  3173. * var other = { 'c': 3, 'd': 4 };
  3174. *
  3175. * var values = _.memoize(_.values);
  3176. * values(object);
  3177. * // => [1, 2]
  3178. *
  3179. * values(other);
  3180. * // => [3, 4]
  3181. *
  3182. * object.a = 2;
  3183. * values(object);
  3184. * // => [1, 2]
  3185. *
  3186. * // Modify the result cache.
  3187. * values.cache.set(object, ['a', 'b']);
  3188. * values(object);
  3189. * // => ['a', 'b']
  3190. *
  3191. * // Replace `_.memoize.Cache`.
  3192. * _.memoize.Cache = WeakMap;
  3193. */
  3194. function memoize(func, resolver) {
  3195. if (typeof func != "function" ||
  3196. (resolver != null && typeof resolver != "function")) {
  3197. throw new TypeError(FUNC_ERROR_TEXT);
  3198. }
  3199. var memoized = function () {
  3200. var args = arguments, key = resolver ? resolver.apply(this, args) : args[0], cache = memoized.cache;
  3201. if (cache.has(key)) {
  3202. return cache.get(key);
  3203. }
  3204. var result = func.apply(this, args);
  3205. memoized.cache = cache.set(key, result) || cache;
  3206. return result;
  3207. };
  3208. memoized.cache = new (memoize.Cache || MapCache)();
  3209. return memoized;
  3210. }
  3211. // Expose `MapCache`.
  3212. memoize.Cache = MapCache;
  3213. /*------------------------------------------------------------------------*/
  3214. /**
  3215. * Performs a
  3216. * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
  3217. * comparison between two values to determine if they are equivalent.
  3218. *
  3219. * @static
  3220. * @memberOf _
  3221. * @since 4.0.0
  3222. * @category Lang
  3223. * @param {*} value The value to compare.
  3224. * @param {*} other The other value to compare.
  3225. * @returns {boolean} Returns `true` if the values are equivalent, else `false`.
  3226. * @example
  3227. *
  3228. * var object = { 'a': 1 };
  3229. * var other = { 'a': 1 };
  3230. *
  3231. * _.eq(object, object);
  3232. * // => true
  3233. *
  3234. * _.eq(object, other);
  3235. * // => false
  3236. *
  3237. * _.eq('a', 'a');
  3238. * // => true
  3239. *
  3240. * _.eq('a', Object('a'));
  3241. * // => false
  3242. *
  3243. * _.eq(NaN, NaN);
  3244. * // => true
  3245. */
  3246. function eq(value, other) {
  3247. return value === other || (value !== value && other !== other);
  3248. }
  3249. /**
  3250. * Checks if `value` is likely an `arguments` object.
  3251. *
  3252. * @static
  3253. * @memberOf _
  3254. * @since 0.1.0
  3255. * @category Lang
  3256. * @param {*} value The value to check.
  3257. * @returns {boolean} Returns `true` if `value` is an `arguments` object,
  3258. * else `false`.
  3259. * @example
  3260. *
  3261. * _.isArguments(function() { return arguments; }());
  3262. * // => true
  3263. *
  3264. * _.isArguments([1, 2, 3]);
  3265. * // => false
  3266. */
  3267. var isArguments = baseIsArguments((function () {
  3268. return arguments;
  3269. })())
  3270. ? baseIsArguments
  3271. : function (value) {
  3272. return (isObjectLike(value) &&
  3273. hasOwnProperty.call(value, "callee") &&
  3274. !propertyIsEnumerable.call(value, "callee"));
  3275. };
  3276. /**
  3277. * Checks if `value` is classified as an `Array` object.
  3278. *
  3279. * @static
  3280. * @memberOf _
  3281. * @since 0.1.0
  3282. * @category Lang
  3283. * @param {*} value The value to check.
  3284. * @returns {boolean} Returns `true` if `value` is an array, else `false`.
  3285. * @example
  3286. *
  3287. * _.isArray([1, 2, 3]);
  3288. * // => true
  3289. *
  3290. * _.isArray(document.body.children);
  3291. * // => false
  3292. *
  3293. * _.isArray('abc');
  3294. * // => false
  3295. *
  3296. * _.isArray(_.noop);
  3297. * // => false
  3298. */
  3299. var isArray = Array.isArray;
  3300. /**
  3301. * Checks if `value` is array-like. A value is considered array-like if it's
  3302. * not a function and has a `value.length` that's an integer greater than or
  3303. * equal to `0` and less than or equal to `Number.MAX_SAFE_INTEGER`.
  3304. *
  3305. * @static
  3306. * @memberOf _
  3307. * @since 4.0.0
  3308. * @category Lang
  3309. * @param {*} value The value to check.
  3310. * @returns {boolean} Returns `true` if `value` is array-like, else `false`.
  3311. * @example
  3312. *
  3313. * _.isArrayLike([1, 2, 3]);
  3314. * // => true
  3315. *
  3316. * _.isArrayLike(document.body.children);
  3317. * // => true
  3318. *
  3319. * _.isArrayLike('abc');
  3320. * // => true
  3321. *
  3322. * _.isArrayLike(_.noop);
  3323. * // => false
  3324. */
  3325. function isArrayLike(value) {
  3326. return value != null && isLength(value.length) && !isFunction(value);
  3327. }
  3328. /**
  3329. * This method is like `_.isArrayLike` except that it also checks if `value`
  3330. * is an object.
  3331. *
  3332. * @static
  3333. * @memberOf _
  3334. * @since 4.0.0
  3335. * @category Lang
  3336. * @param {*} value The value to check.
  3337. * @returns {boolean} Returns `true` if `value` is an array-like object,
  3338. * else `false`.
  3339. * @example
  3340. *
  3341. * _.isArrayLikeObject([1, 2, 3]);
  3342. * // => true
  3343. *
  3344. * _.isArrayLikeObject(document.body.children);
  3345. * // => true
  3346. *
  3347. * _.isArrayLikeObject('abc');
  3348. * // => false
  3349. *
  3350. * _.isArrayLikeObject(_.noop);
  3351. * // => false
  3352. */
  3353. function isArrayLikeObject(value) {
  3354. return isObjectLike(value) && isArrayLike(value);
  3355. }
  3356. /**
  3357. * Checks if `value` is a buffer.
  3358. *
  3359. * @static
  3360. * @memberOf _
  3361. * @since 4.3.0
  3362. * @category Lang
  3363. * @param {*} value The value to check.
  3364. * @returns {boolean} Returns `true` if `value` is a buffer, else `false`.
  3365. * @example
  3366. *
  3367. * _.isBuffer(new Buffer(2));
  3368. * // => true
  3369. *
  3370. * _.isBuffer(new Uint8Array(2));
  3371. * // => false
  3372. */
  3373. var isBuffer = nativeIsBuffer || stubFalse;
  3374. /**
  3375. * Checks if `value` is classified as a `Function` object.
  3376. *
  3377. * @static
  3378. * @memberOf _
  3379. * @since 0.1.0
  3380. * @category Lang
  3381. * @param {*} value The value to check.
  3382. * @returns {boolean} Returns `true` if `value` is a function, else `false`.
  3383. * @example
  3384. *
  3385. * _.isFunction(_);
  3386. * // => true
  3387. *
  3388. * _.isFunction(/abc/);
  3389. * // => false
  3390. */
  3391. function isFunction(value) {
  3392. if (!isObject(value)) {
  3393. return false;
  3394. }
  3395. // The use of `Object#toString` avoids issues with the `typeof` operator
  3396. // in Safari 9 which returns 'object' for typed arrays and other constructors.
  3397. var tag = baseGetTag(value);
  3398. return (tag == funcTag ||
  3399. tag == genTag ||
  3400. tag == asyncTag ||
  3401. tag == proxyTag);
  3402. }
  3403. /**
  3404. * Checks if `value` is a valid array-like length.
  3405. *
  3406. * **Note:** This method is loosely based on
  3407. * [`ToLength`](http://ecma-international.org/ecma-262/7.0/#sec-tolength).
  3408. *
  3409. * @static
  3410. * @memberOf _
  3411. * @since 4.0.0
  3412. * @category Lang
  3413. * @param {*} value The value to check.
  3414. * @returns {boolean} Returns `true` if `value` is a valid length, else `false`.
  3415. * @example
  3416. *
  3417. * _.isLength(3);
  3418. * // => true
  3419. *
  3420. * _.isLength(Number.MIN_VALUE);
  3421. * // => false
  3422. *
  3423. * _.isLength(Infinity);
  3424. * // => false
  3425. *
  3426. * _.isLength('3');
  3427. * // => false
  3428. */
  3429. function isLength(value) {
  3430. return (typeof value == "number" &&
  3431. value > -1 &&
  3432. value % 1 == 0 &&
  3433. value <= MAX_SAFE_INTEGER);
  3434. }
  3435. /**
  3436. * Checks if `value` is the
  3437. * [language type](http://www.ecma-international.org/ecma-262/7.0/#sec-ecmascript-language-types)
  3438. * of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)
  3439. *
  3440. * @static
  3441. * @memberOf _
  3442. * @since 0.1.0
  3443. * @category Lang
  3444. * @param {*} value The value to check.
  3445. * @returns {boolean} Returns `true` if `value` is an object, else `false`.
  3446. * @example
  3447. *
  3448. * _.isObject({});
  3449. * // => true
  3450. *
  3451. * _.isObject([1, 2, 3]);
  3452. * // => true
  3453. *
  3454. * _.isObject(_.noop);
  3455. * // => true
  3456. *
  3457. * _.isObject(null);
  3458. * // => false
  3459. */
  3460. function isObject(value) {
  3461. var type = typeof value;
  3462. return value != null && (type == "object" || type == "function");
  3463. }
  3464. /**
  3465. * Checks if `value` is object-like. A value is object-like if it's not `null`
  3466. * and has a `typeof` result of "object".
  3467. *
  3468. * @static
  3469. * @memberOf _
  3470. * @since 4.0.0
  3471. * @category Lang
  3472. * @param {*} value The value to check.
  3473. * @returns {boolean} Returns `true` if `value` is object-like, else `false`.
  3474. * @example
  3475. *
  3476. * _.isObjectLike({});
  3477. * // => true
  3478. *
  3479. * _.isObjectLike([1, 2, 3]);
  3480. * // => true
  3481. *
  3482. * _.isObjectLike(_.noop);
  3483. * // => false
  3484. *
  3485. * _.isObjectLike(null);
  3486. * // => false
  3487. */
  3488. function isObjectLike(value) {
  3489. return value != null && typeof value == "object";
  3490. }
  3491. /**
  3492. * Checks if `value` is a plain object, that is, an object created by the
  3493. * `Object` constructor or one with a `[[Prototype]]` of `null`.
  3494. *
  3495. * @static
  3496. * @memberOf _
  3497. * @since 0.8.0
  3498. * @category Lang
  3499. * @param {*} value The value to check.
  3500. * @returns {boolean} Returns `true` if `value` is a plain object, else `false`.
  3501. * @example
  3502. *
  3503. * function Foo() {
  3504. * this.a = 1;
  3505. * }
  3506. *
  3507. * _.isPlainObject(new Foo);
  3508. * // => false
  3509. *
  3510. * _.isPlainObject([1, 2, 3]);
  3511. * // => false
  3512. *
  3513. * _.isPlainObject({ 'x': 0, 'y': 0 });
  3514. * // => true
  3515. *
  3516. * _.isPlainObject(Object.create(null));
  3517. * // => true
  3518. */
  3519. function isPlainObject(value) {
  3520. if (!isObjectLike(value) || baseGetTag(value) != objectTag) {
  3521. return false;
  3522. }
  3523. var proto = getPrototype(value);
  3524. if (proto === null) {
  3525. return true;
  3526. }
  3527. var Ctor = hasOwnProperty.call(proto, "constructor") && proto.constructor;
  3528. return (typeof Ctor == "function" &&
  3529. Ctor instanceof Ctor &&
  3530. funcToString.call(Ctor) == objectCtorString);
  3531. }
  3532. /**
  3533. * Checks if `value` is classified as a `String` primitive or object.
  3534. *
  3535. * @static
  3536. * @since 0.1.0
  3537. * @memberOf _
  3538. * @category Lang
  3539. * @param {*} value The value to check.
  3540. * @returns {boolean} Returns `true` if `value` is a string, else `false`.
  3541. * @example
  3542. *
  3543. * _.isString('abc');
  3544. * // => true
  3545. *
  3546. * _.isString(1);
  3547. * // => false
  3548. */
  3549. function isString(value) {
  3550. return (typeof value == "string" ||
  3551. (!isArray(value) &&
  3552. isObjectLike(value) &&
  3553. baseGetTag(value) == stringTag));
  3554. }
  3555. /**
  3556. * Checks if `value` is classified as a `Symbol` primitive or object.
  3557. *
  3558. * @static
  3559. * @memberOf _
  3560. * @since 4.0.0
  3561. * @category Lang
  3562. * @param {*} value The value to check.
  3563. * @returns {boolean} Returns `true` if `value` is a symbol, else `false`.
  3564. * @example
  3565. *
  3566. * _.isSymbol(Symbol.iterator);
  3567. * // => true
  3568. *
  3569. * _.isSymbol('abc');
  3570. * // => false
  3571. */
  3572. function isSymbol(value) {
  3573. return (typeof value == "symbol" ||
  3574. (isObjectLike(value) && baseGetTag(value) == symbolTag));
  3575. }
  3576. /**
  3577. * Checks if `value` is classified as a typed array.
  3578. *
  3579. * @static
  3580. * @memberOf _
  3581. * @since 3.0.0
  3582. * @category Lang
  3583. * @param {*} value The value to check.
  3584. * @returns {boolean} Returns `true` if `value` is a typed array, else `false`.
  3585. * @example
  3586. *
  3587. * _.isTypedArray(new Uint8Array);
  3588. * // => true
  3589. *
  3590. * _.isTypedArray([]);
  3591. * // => false
  3592. */
  3593. var isTypedArray = nodeIsTypedArray
  3594. ? baseUnary(nodeIsTypedArray)
  3595. : baseIsTypedArray;
  3596. /**
  3597. * Checks if `value` is `undefined`.
  3598. *
  3599. * @static
  3600. * @since 0.1.0
  3601. * @memberOf _
  3602. * @category Lang
  3603. * @param {*} value The value to check.
  3604. * @returns {boolean} Returns `true` if `value` is `undefined`, else `false`.
  3605. * @example
  3606. *
  3607. * _.isUndefined(void 0);
  3608. * // => true
  3609. *
  3610. * _.isUndefined(null);
  3611. * // => false
  3612. */
  3613. function isUndefined(value) {
  3614. return value === undefined;
  3615. }
  3616. /**
  3617. * Converts `value` to an array.
  3618. *
  3619. * @static
  3620. * @since 0.1.0
  3621. * @memberOf _
  3622. * @category Lang
  3623. * @param {*} value The value to convert.
  3624. * @returns {Array} Returns the converted array.
  3625. * @example
  3626. *
  3627. * _.toArray({ 'a': 1, 'b': 2 });
  3628. * // => [1, 2]
  3629. *
  3630. * _.toArray('abc');
  3631. * // => ['a', 'b', 'c']
  3632. *
  3633. * _.toArray(1);
  3634. * // => []
  3635. *
  3636. * _.toArray(null);
  3637. * // => []
  3638. */
  3639. function toArray(value) {
  3640. if (!value) {
  3641. return [];
  3642. }
  3643. if (isArrayLike(value)) {
  3644. return isString(value) ? stringToArray(value) : copyArray(value);
  3645. }
  3646. if (symIterator && value[symIterator]) {
  3647. return iteratorToArray(value[symIterator]());
  3648. }
  3649. var tag = getTag(value), func = tag == mapTag
  3650. ? mapToArray
  3651. : tag == setTag
  3652. ? setToArray
  3653. : values;
  3654. return func(value);
  3655. }
  3656. /**
  3657. * Converts `value` to a finite number.
  3658. *
  3659. * @static
  3660. * @memberOf _
  3661. * @since 4.12.0
  3662. * @category Lang
  3663. * @param {*} value The value to convert.
  3664. * @returns {number} Returns the converted number.
  3665. * @example
  3666. *
  3667. * _.toFinite(3.2);
  3668. * // => 3.2
  3669. *
  3670. * _.toFinite(Number.MIN_VALUE);
  3671. * // => 5e-324
  3672. *
  3673. * _.toFinite(Infinity);
  3674. * // => 1.7976931348623157e+308
  3675. *
  3676. * _.toFinite('3.2');
  3677. * // => 3.2
  3678. */
  3679. function toFinite(value) {
  3680. if (!value) {
  3681. return value === 0 ? value : 0;
  3682. }
  3683. value = toNumber(value);
  3684. if (value === INFINITY || value === -INFINITY) {
  3685. var sign = value < 0 ? -1 : 1;
  3686. return sign * MAX_INTEGER;
  3687. }
  3688. return value === value ? value : 0;
  3689. }
  3690. /**
  3691. * Converts `value` to an integer.
  3692. *
  3693. * **Note:** This method is loosely based on
  3694. * [`ToInteger`](http://www.ecma-international.org/ecma-262/7.0/#sec-tointeger).
  3695. *
  3696. * @static
  3697. * @memberOf _
  3698. * @since 4.0.0
  3699. * @category Lang
  3700. * @param {*} value The value to convert.
  3701. * @returns {number} Returns the converted integer.
  3702. * @example
  3703. *
  3704. * _.toInteger(3.2);
  3705. * // => 3
  3706. *
  3707. * _.toInteger(Number.MIN_VALUE);
  3708. * // => 0
  3709. *
  3710. * _.toInteger(Infinity);
  3711. * // => 1.7976931348623157e+308
  3712. *
  3713. * _.toInteger('3.2');
  3714. * // => 3
  3715. */
  3716. function toInteger(value) {
  3717. var result = toFinite(value), remainder = result % 1;
  3718. return result === result
  3719. ? remainder
  3720. ? result - remainder
  3721. : result
  3722. : 0;
  3723. }
  3724. /**
  3725. * Converts `value` to a number.
  3726. *
  3727. * @static
  3728. * @memberOf _
  3729. * @since 4.0.0
  3730. * @category Lang
  3731. * @param {*} value The value to process.
  3732. * @returns {number} Returns the number.
  3733. * @example
  3734. *
  3735. * _.toNumber(3.2);
  3736. * // => 3.2
  3737. *
  3738. * _.toNumber(Number.MIN_VALUE);
  3739. * // => 5e-324
  3740. *
  3741. * _.toNumber(Infinity);
  3742. * // => Infinity
  3743. *
  3744. * _.toNumber('3.2');
  3745. * // => 3.2
  3746. */
  3747. function toNumber(value) {
  3748. if (typeof value == "number") {
  3749. return value;
  3750. }
  3751. if (isSymbol(value)) {
  3752. return NAN;
  3753. }
  3754. if (isObject(value)) {
  3755. var other = typeof value.valueOf == "function" ? value.valueOf() : value;
  3756. value = isObject(other) ? other + "" : other;
  3757. }
  3758. if (typeof value != "string") {
  3759. return value === 0 ? value : +value;
  3760. }
  3761. value = value.replace(reTrim, "");
  3762. var isBinary = reIsBinary.test(value);
  3763. return isBinary || reIsOctal.test(value)
  3764. ? freeParseInt(value.slice(2), isBinary ? 2 : 8)
  3765. : reIsBadHex.test(value)
  3766. ? NAN
  3767. : +value;
  3768. }
  3769. /**
  3770. * Converts `value` to a plain object flattening inherited enumerable string
  3771. * keyed properties of `value` to own properties of the plain object.
  3772. *
  3773. * @static
  3774. * @memberOf _
  3775. * @since 3.0.0
  3776. * @category Lang
  3777. * @param {*} value The value to convert.
  3778. * @returns {Object} Returns the converted plain object.
  3779. * @example
  3780. *
  3781. * function Foo() {
  3782. * this.b = 2;
  3783. * }
  3784. *
  3785. * Foo.prototype.c = 3;
  3786. *
  3787. * _.assign({ 'a': 1 }, new Foo);
  3788. * // => { 'a': 1, 'b': 2 }
  3789. *
  3790. * _.assign({ 'a': 1 }, _.toPlainObject(new Foo));
  3791. * // => { 'a': 1, 'b': 2, 'c': 3 }
  3792. */
  3793. function toPlainObject(value) {
  3794. return copyObject(value, keysIn(value));
  3795. }
  3796. /**
  3797. * Converts `value` to a string. An empty string is returned for `null`
  3798. * and `undefined` values. The sign of `-0` is preserved.
  3799. *
  3800. * @static
  3801. * @memberOf _
  3802. * @since 4.0.0
  3803. * @category Lang
  3804. * @param {*} value The value to convert.
  3805. * @returns {string} Returns the converted string.
  3806. * @example
  3807. *
  3808. * _.toString(null);
  3809. * // => ''
  3810. *
  3811. * _.toString(-0);
  3812. * // => '-0'
  3813. *
  3814. * _.toString([1, 2, 3]);
  3815. * // => '1,2,3'
  3816. */
  3817. function toString(value) {
  3818. return value == null ? "" : baseToString(value);
  3819. }
  3820. /*------------------------------------------------------------------------*/
  3821. /**
  3822. * Gets the value at `path` of `object`. If the resolved value is
  3823. * `undefined`, the `defaultValue` is returned in its place.
  3824. *
  3825. * @static
  3826. * @memberOf _
  3827. * @since 3.7.0
  3828. * @category Object
  3829. * @param {Object} object The object to query.
  3830. * @param {Array|string} path The path of the property to get.
  3831. * @param {*} [defaultValue] The value returned for `undefined` resolved values.
  3832. * @returns {*} Returns the resolved value.
  3833. * @example
  3834. *
  3835. * var object = { 'a': [{ 'b': { 'c': 3 } }] };
  3836. *
  3837. * _.get(object, 'a[0].b.c');
  3838. * // => 3
  3839. *
  3840. * _.get(object, ['a', '0', 'b', 'c']);
  3841. * // => 3
  3842. *
  3843. * _.get(object, 'a.b.c', 'default');
  3844. * // => 'default'
  3845. */
  3846. function get(object, path, defaultValue) {
  3847. var result = object == null ? undefined : baseGet(object, path);
  3848. return result === undefined ? defaultValue : result;
  3849. }
  3850. /**
  3851. * Checks if `path` is a direct or inherited property of `object`.
  3852. *
  3853. * @static
  3854. * @memberOf _
  3855. * @since 4.0.0
  3856. * @category Object
  3857. * @param {Object} object The object to query.
  3858. * @param {Array|string} path The path to check.
  3859. * @returns {boolean} Returns `true` if `path` exists, else `false`.
  3860. * @example
  3861. *
  3862. * var object = _.create({ 'a': _.create({ 'b': 2 }) });
  3863. *
  3864. * _.hasIn(object, 'a');
  3865. * // => true
  3866. *
  3867. * _.hasIn(object, 'a.b');
  3868. * // => true
  3869. *
  3870. * _.hasIn(object, ['a', 'b']);
  3871. * // => true
  3872. *
  3873. * _.hasIn(object, 'b');
  3874. * // => false
  3875. */
  3876. function hasIn(object, path) {
  3877. return object != null && hasPath(object, path, baseHasIn);
  3878. }
  3879. /**
  3880. * Creates an array of the own enumerable property names of `object`.
  3881. *
  3882. * **Note:** Non-object values are coerced to objects. See the
  3883. * [ES spec](http://ecma-international.org/ecma-262/7.0/#sec-object.keys)
  3884. * for more details.
  3885. *
  3886. * @static
  3887. * @since 0.1.0
  3888. * @memberOf _
  3889. * @category Object
  3890. * @param {Object} object The object to query.
  3891. * @returns {Array} Returns the array of property names.
  3892. * @example
  3893. *
  3894. * function Foo() {
  3895. * this.a = 1;
  3896. * this.b = 2;
  3897. * }
  3898. *
  3899. * Foo.prototype.c = 3;
  3900. *
  3901. * _.keys(new Foo);
  3902. * // => ['a', 'b'] (iteration order is not guaranteed)
  3903. *
  3904. * _.keys('hi');
  3905. * // => ['0', '1']
  3906. */
  3907. function keys(object) {
  3908. return isArrayLike(object) ? arrayLikeKeys(object) : baseKeys(object);
  3909. }
  3910. /**
  3911. * Creates an array of the own and inherited enumerable property names of `object`.
  3912. *
  3913. * **Note:** Non-object values are coerced to objects.
  3914. *
  3915. * @static
  3916. * @memberOf _
  3917. * @since 3.0.0
  3918. * @category Object
  3919. * @param {Object} object The object to query.
  3920. * @returns {Array} Returns the array of property names.
  3921. * @example
  3922. *
  3923. * function Foo() {
  3924. * this.a = 1;
  3925. * this.b = 2;
  3926. * }
  3927. *
  3928. * Foo.prototype.c = 3;
  3929. *
  3930. * _.keysIn(new Foo);
  3931. * // => ['a', 'b', 'c'] (iteration order is not guaranteed)
  3932. */
  3933. function keysIn(object) {
  3934. return isArrayLike(object)
  3935. ? arrayLikeKeys(object, true)
  3936. : baseKeysIn(object);
  3937. }
  3938. /**
  3939. * This method is like `_.assign` except that it recursively merges own and
  3940. * inherited enumerable string keyed properties of source objects into the
  3941. * destination object. Source properties that resolve to `undefined` are
  3942. * skipped if a destination value exists. Array and plain object properties
  3943. * are merged recursively. Other objects and value types are overridden by
  3944. * assignment. Source objects are applied from left to right. Subsequent
  3945. * sources overwrite property assignments of previous sources.
  3946. *
  3947. * **Note:** This method mutates `object`.
  3948. *
  3949. * @static
  3950. * @memberOf _
  3951. * @since 0.5.0
  3952. * @category Object
  3953. * @param {Object} object The destination object.
  3954. * @param {...Object} [sources] The source objects.
  3955. * @returns {Object} Returns `object`.
  3956. * @example
  3957. *
  3958. * var object = {
  3959. * 'a': [{ 'b': 2 }, { 'd': 4 }]
  3960. * };
  3961. *
  3962. * var other = {
  3963. * 'a': [{ 'c': 3 }, { 'e': 5 }]
  3964. * };
  3965. *
  3966. * _.merge(object, other);
  3967. * // => { 'a': [{ 'b': 2, 'c': 3 }, { 'd': 4, 'e': 5 }] }
  3968. */
  3969. var merge = createAssigner(function (object, source, srcIndex) {
  3970. baseMerge(object, source, srcIndex);
  3971. });
  3972. /**
  3973. * Sets the value at `path` of `object`. If a portion of `path` doesn't exist,
  3974. * it's created. Arrays are created for missing index properties while objects
  3975. * are created for all other missing properties. Use `_.setWith` to customize
  3976. * `path` creation.
  3977. *
  3978. * **Note:** This method mutates `object`.
  3979. *
  3980. * @static
  3981. * @memberOf _
  3982. * @since 3.7.0
  3983. * @category Object
  3984. * @param {Object} object The object to modify.
  3985. * @param {Array|string} path The path of the property to set.
  3986. * @param {*} value The value to set.
  3987. * @returns {Object} Returns `object`.
  3988. * @example
  3989. *
  3990. * var object = { 'a': [{ 'b': { 'c': 3 } }] };
  3991. *
  3992. * _.set(object, 'a[0].b.c', 4);
  3993. * console.log(object.a[0].b.c);
  3994. * // => 4
  3995. *
  3996. * _.set(object, ['x', '0', 'y', 'z'], 5);
  3997. * console.log(object.x[0].y.z);
  3998. * // => 5
  3999. */
  4000. function set(object, path, value) {
  4001. return object == null ? object : baseSet(object, path, value);
  4002. }
  4003. /**
  4004. * Creates an array of the own enumerable string keyed property values of `object`.
  4005. *
  4006. * **Note:** Non-object values are coerced to objects.
  4007. *
  4008. * @static
  4009. * @since 0.1.0
  4010. * @memberOf _
  4011. * @category Object
  4012. * @param {Object} object The object to query.
  4013. * @returns {Array} Returns the array of property values.
  4014. * @example
  4015. *
  4016. * function Foo() {
  4017. * this.a = 1;
  4018. * this.b = 2;
  4019. * }
  4020. *
  4021. * Foo.prototype.c = 3;
  4022. *
  4023. * _.values(new Foo);
  4024. * // => [1, 2] (iteration order is not guaranteed)
  4025. *
  4026. * _.values('hi');
  4027. * // => ['h', 'i']
  4028. */
  4029. function values(object) {
  4030. return object == null ? [] : baseValues(object, keys(object));
  4031. }
  4032. /*------------------------------------------------------------------------*/
  4033. /**
  4034. * Creates a function that returns `value`.
  4035. *
  4036. * @static
  4037. * @memberOf _
  4038. * @since 2.4.0
  4039. * @category Util
  4040. * @param {*} value The value to return from the new function.
  4041. * @returns {Function} Returns the new constant function.
  4042. * @example
  4043. *
  4044. * var objects = _.times(2, _.constant({ 'a': 1 }));
  4045. *
  4046. * console.log(objects);
  4047. * // => [{ 'a': 1 }, { 'a': 1 }]
  4048. *
  4049. * console.log(objects[0] === objects[1]);
  4050. * // => true
  4051. */
  4052. function constant(value) {
  4053. return function () {
  4054. return value;
  4055. };
  4056. }
  4057. /**
  4058. * This method returns the first argument it receives.
  4059. *
  4060. * @static
  4061. * @since 0.1.0
  4062. * @memberOf _
  4063. * @category Util
  4064. * @param {*} value Any value.
  4065. * @returns {*} Returns `value`.
  4066. * @example
  4067. *
  4068. * var object = { 'a': 1 };
  4069. *
  4070. * console.log(_.identity(object) === object);
  4071. * // => true
  4072. */
  4073. function identity(value) {
  4074. return value;
  4075. }
  4076. /**
  4077. * Creates a function that invokes `func` with the arguments of the created
  4078. * function. If `func` is a property name, the created function returns the
  4079. * property value for a given element. If `func` is an array or object, the
  4080. * created function returns `true` for elements that contain the equivalent
  4081. * source properties, otherwise it returns `false`.
  4082. *
  4083. * @static
  4084. * @since 4.0.0
  4085. * @memberOf _
  4086. * @category Util
  4087. * @param {*} [func=_.identity] The value to convert to a callback.
  4088. * @returns {Function} Returns the callback.
  4089. * @example
  4090. *
  4091. * var users = [
  4092. * { 'user': 'barney', 'age': 36, 'active': true },
  4093. * { 'user': 'fred', 'age': 40, 'active': false }
  4094. * ];
  4095. *
  4096. * // The `_.matches` iteratee shorthand.
  4097. * _.filter(users, _.iteratee({ 'user': 'barney', 'active': true }));
  4098. * // => [{ 'user': 'barney', 'age': 36, 'active': true }]
  4099. *
  4100. * // The `_.matchesProperty` iteratee shorthand.
  4101. * _.filter(users, _.iteratee(['user', 'fred']));
  4102. * // => [{ 'user': 'fred', 'age': 40 }]
  4103. *
  4104. * // The `_.property` iteratee shorthand.
  4105. * _.map(users, _.iteratee('user'));
  4106. * // => ['barney', 'fred']
  4107. *
  4108. * // Create custom iteratee shorthands.
  4109. * _.iteratee = _.wrap(_.iteratee, function(iteratee, func) {
  4110. * return !_.isRegExp(func) ? iteratee(func) : function(string) {
  4111. * return func.test(string);
  4112. * };
  4113. * });
  4114. *
  4115. * _.filter(['abc', 'def'], /ef/);
  4116. * // => ['def']
  4117. */
  4118. function iteratee(func) {
  4119. return baseIteratee(typeof func == "function" ? func : baseClone(func, CLONE_DEEP_FLAG));
  4120. }
  4121. /**
  4122. * This method returns `undefined`.
  4123. *
  4124. * @static
  4125. * @memberOf _
  4126. * @since 2.3.0
  4127. * @category Util
  4128. * @example
  4129. *
  4130. * _.times(2, _.noop);
  4131. * // => [undefined, undefined]
  4132. */
  4133. function noop() {
  4134. // No operation performed.
  4135. }
  4136. /**
  4137. * Creates a function that returns the value at `path` of a given object.
  4138. *
  4139. * @static
  4140. * @memberOf _
  4141. * @since 2.4.0
  4142. * @category Util
  4143. * @param {Array|string} path The path of the property to get.
  4144. * @returns {Function} Returns the new accessor function.
  4145. * @example
  4146. *
  4147. * var objects = [
  4148. * { 'a': { 'b': 2 } },
  4149. * { 'a': { 'b': 1 } }
  4150. * ];
  4151. *
  4152. * _.map(objects, _.property('a.b'));
  4153. * // => [2, 1]
  4154. *
  4155. * _.map(_.sortBy(objects, _.property(['a', 'b'])), 'a.b');
  4156. * // => [1, 2]
  4157. */
  4158. function property(path) {
  4159. return isKey(path) ? baseProperty(toKey(path)) : basePropertyDeep(path);
  4160. }
  4161. /**
  4162. * This method returns a new empty array.
  4163. *
  4164. * @static
  4165. * @memberOf _
  4166. * @since 4.13.0
  4167. * @category Util
  4168. * @returns {Array} Returns the new empty array.
  4169. * @example
  4170. *
  4171. * var arrays = _.times(2, _.stubArray);
  4172. *
  4173. * console.log(arrays);
  4174. * // => [[], []]
  4175. *
  4176. * console.log(arrays[0] === arrays[1]);
  4177. * // => false
  4178. */
  4179. function stubArray() {
  4180. return [];
  4181. }
  4182. /**
  4183. * This method returns `false`.
  4184. *
  4185. * @static
  4186. * @memberOf _
  4187. * @since 4.13.0
  4188. * @category Util
  4189. * @returns {boolean} Returns `false`.
  4190. * @example
  4191. *
  4192. * _.times(2, _.stubFalse);
  4193. * // => [false, false]
  4194. */
  4195. function stubFalse() {
  4196. return false;
  4197. }
  4198. /*------------------------------------------------------------------------*/
  4199. // Add methods that return wrapped values in chain sequences.
  4200. lodash.constant = constant;
  4201. lodash.iteratee = iteratee;
  4202. lodash.keys = keys;
  4203. lodash.keysIn = keysIn;
  4204. lodash.memoize = memoize;
  4205. lodash.merge = merge;
  4206. lodash.property = property;
  4207. lodash.set = set;
  4208. lodash.toArray = toArray;
  4209. lodash.toPlainObject = toPlainObject;
  4210. lodash.union = union;
  4211. lodash.values = values;
  4212. /*------------------------------------------------------------------------*/
  4213. // Add methods that return unwrapped values in chain sequences.
  4214. lodash.eq = eq;
  4215. lodash.forEach = forEach;
  4216. lodash.get = get;
  4217. lodash.hasIn = hasIn;
  4218. lodash.identity = identity;
  4219. lodash.includes = includes;
  4220. lodash.isArguments = isArguments;
  4221. lodash.isArray = isArray;
  4222. lodash.isArrayLike = isArrayLike;
  4223. lodash.isArrayLikeObject = isArrayLikeObject;
  4224. lodash.isBuffer = isBuffer;
  4225. lodash.isFunction = isFunction;
  4226. lodash.isLength = isLength;
  4227. lodash.isObject = isObject;
  4228. lodash.isObjectLike = isObjectLike;
  4229. lodash.isPlainObject = isPlainObject;
  4230. lodash.isString = isString;
  4231. lodash.isSymbol = isSymbol;
  4232. lodash.isTypedArray = isTypedArray;
  4233. lodash.isUndefined = isUndefined;
  4234. lodash.stubArray = stubArray;
  4235. lodash.stubFalse = stubFalse;
  4236. lodash.noop = noop;
  4237. lodash.toFinite = toFinite;
  4238. lodash.toInteger = toInteger;
  4239. lodash.toNumber = toNumber;
  4240. lodash.toString = toString;
  4241. // Add aliases.
  4242. lodash.each = forEach;
  4243. /*------------------------------------------------------------------------*/
  4244. /**
  4245. * The semantic version number.
  4246. *
  4247. * @static
  4248. * @memberOf _
  4249. * @type {string}
  4250. */
  4251. lodash.VERSION = VERSION;
  4252. /*--------------------------------------------------------------------------*/
  4253. if (freeModule) {
  4254. // Export for Node.js.
  4255. (freeModule.exports = lodash)._ = lodash;
  4256. // Export for CommonJS support.
  4257. freeExports._ = lodash;
  4258. }
  4259. }.call(this));
  4260. //# sourceMappingURL=lodash.custom.js.map