lodash.custom.js 148 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248
  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 ? getAllKeysIn : getAllKeys
  1362. : isFlat ? keysIn : keys;
  1363. var props = isArr ? undefined : keysFunc(value);
  1364. arrayEach(props || value, function (subValue, key) {
  1365. if (props) {
  1366. key = subValue;
  1367. subValue = value[key];
  1368. }
  1369. // Recursively populate clone (susceptible to call stack limits).
  1370. assignValue(result, key, baseClone(subValue, bitmask, customizer, key, value, stack));
  1371. });
  1372. return result;
  1373. }
  1374. /**
  1375. * The base implementation of `_.forEach` without support for iteratee shorthands.
  1376. *
  1377. * @private
  1378. * @param {Array|Object} collection The collection to iterate over.
  1379. * @param {Function} iteratee The function invoked per iteration.
  1380. * @returns {Array|Object} Returns `collection`.
  1381. */
  1382. var baseEach = createBaseEach(baseForOwn);
  1383. /**
  1384. * The base implementation of `_.flatten` with support for restricting flattening.
  1385. *
  1386. * @private
  1387. * @param {Array} array The array to flatten.
  1388. * @param {number} depth The maximum recursion depth.
  1389. * @param {boolean} [predicate=isFlattenable] The function invoked per iteration.
  1390. * @param {boolean} [isStrict] Restrict to values that pass `predicate` checks.
  1391. * @param {Array} [result=[]] The initial result value.
  1392. * @returns {Array} Returns the new flattened array.
  1393. */
  1394. function baseFlatten(array, depth, predicate, isStrict, result) {
  1395. var index = -1, length = array.length;
  1396. predicate || (predicate = isFlattenable);
  1397. result || (result = []);
  1398. while (++index < length) {
  1399. var value = array[index];
  1400. if (depth > 0 && predicate(value)) {
  1401. if (depth > 1) {
  1402. // Recursively flatten arrays (susceptible to call stack limits).
  1403. baseFlatten(value, depth - 1, predicate, isStrict, result);
  1404. }
  1405. else {
  1406. arrayPush(result, value);
  1407. }
  1408. }
  1409. else if (!isStrict) {
  1410. result[result.length] = value;
  1411. }
  1412. }
  1413. return result;
  1414. }
  1415. /**
  1416. * The base implementation of `baseForOwn` which iterates over `object`
  1417. * properties returned by `keysFunc` and invokes `iteratee` for each property.
  1418. * Iteratee functions may exit iteration early by explicitly returning `false`.
  1419. *
  1420. * @private
  1421. * @param {Object} object The object to iterate over.
  1422. * @param {Function} iteratee The function invoked per iteration.
  1423. * @param {Function} keysFunc The function to get the keys of `object`.
  1424. * @returns {Object} Returns `object`.
  1425. */
  1426. var baseFor = createBaseFor();
  1427. /**
  1428. * The base implementation of `_.forOwn` without support for iteratee shorthands.
  1429. *
  1430. * @private
  1431. * @param {Object} object The object to iterate over.
  1432. * @param {Function} iteratee The function invoked per iteration.
  1433. * @returns {Object} Returns `object`.
  1434. */
  1435. function baseForOwn(object, iteratee) {
  1436. return object && baseFor(object, iteratee, keys);
  1437. }
  1438. /**
  1439. * The base implementation of `_.get` without support for default values.
  1440. *
  1441. * @private
  1442. * @param {Object} object The object to query.
  1443. * @param {Array|string} path The path of the property to get.
  1444. * @returns {*} Returns the resolved value.
  1445. */
  1446. function baseGet(object, path) {
  1447. path = castPath(path, object);
  1448. var index = 0, length = path.length;
  1449. while (object != null && index < length) {
  1450. object = object[toKey(path[index++])];
  1451. }
  1452. return index && index == length ? object : undefined;
  1453. }
  1454. /**
  1455. * The base implementation of `getAllKeys` and `getAllKeysIn` which uses
  1456. * `keysFunc` and `symbolsFunc` to get the enumerable property names and
  1457. * symbols of `object`.
  1458. *
  1459. * @private
  1460. * @param {Object} object The object to query.
  1461. * @param {Function} keysFunc The function to get the keys of `object`.
  1462. * @param {Function} symbolsFunc The function to get the symbols of `object`.
  1463. * @returns {Array} Returns the array of property names and symbols.
  1464. */
  1465. function baseGetAllKeys(object, keysFunc, symbolsFunc) {
  1466. var result = keysFunc(object);
  1467. return isArray(object)
  1468. ? result
  1469. : arrayPush(result, symbolsFunc(object));
  1470. }
  1471. /**
  1472. * The base implementation of `getTag` without fallbacks for buggy environments.
  1473. *
  1474. * @private
  1475. * @param {*} value The value to query.
  1476. * @returns {string} Returns the `toStringTag`.
  1477. */
  1478. function baseGetTag(value) {
  1479. if (value == null) {
  1480. return value === undefined ? undefinedTag : nullTag;
  1481. }
  1482. return symToStringTag && symToStringTag in Object(value)
  1483. ? getRawTag(value)
  1484. : objectToString(value);
  1485. }
  1486. /**
  1487. * The base implementation of `_.hasIn` without support for deep paths.
  1488. *
  1489. * @private
  1490. * @param {Object} [object] The object to query.
  1491. * @param {Array|string} key The key to check.
  1492. * @returns {boolean} Returns `true` if `key` exists, else `false`.
  1493. */
  1494. function baseHasIn(object, key) {
  1495. return object != null && key in Object(object);
  1496. }
  1497. /**
  1498. * The base implementation of `_.isArguments`.
  1499. *
  1500. * @private
  1501. * @param {*} value The value to check.
  1502. * @returns {boolean} Returns `true` if `value` is an `arguments` object,
  1503. */
  1504. function baseIsArguments(value) {
  1505. return isObjectLike(value) && baseGetTag(value) == argsTag;
  1506. }
  1507. /**
  1508. * The base implementation of `_.isEqual` which supports partial comparisons
  1509. * and tracks traversed objects.
  1510. *
  1511. * @private
  1512. * @param {*} value The value to compare.
  1513. * @param {*} other The other value to compare.
  1514. * @param {boolean} bitmask The bitmask flags.
  1515. * 1 - Unordered comparison
  1516. * 2 - Partial comparison
  1517. * @param {Function} [customizer] The function to customize comparisons.
  1518. * @param {Object} [stack] Tracks traversed `value` and `other` objects.
  1519. * @returns {boolean} Returns `true` if the values are equivalent, else `false`.
  1520. */
  1521. function baseIsEqual(value, other, bitmask, customizer, stack) {
  1522. if (value === other) {
  1523. return true;
  1524. }
  1525. if (value == null ||
  1526. other == null ||
  1527. (!isObjectLike(value) && !isObjectLike(other))) {
  1528. return value !== value && other !== other;
  1529. }
  1530. return baseIsEqualDeep(value, other, bitmask, customizer, baseIsEqual, stack);
  1531. }
  1532. /**
  1533. * A specialized version of `baseIsEqual` for arrays and objects which performs
  1534. * deep comparisons and tracks traversed objects enabling objects with circular
  1535. * references to be compared.
  1536. *
  1537. * @private
  1538. * @param {Object} object The object to compare.
  1539. * @param {Object} other The other object to compare.
  1540. * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.
  1541. * @param {Function} customizer The function to customize comparisons.
  1542. * @param {Function} equalFunc The function to determine equivalents of values.
  1543. * @param {Object} [stack] Tracks traversed `object` and `other` objects.
  1544. * @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
  1545. */
  1546. function baseIsEqualDeep(object, other, bitmask, customizer, equalFunc, stack) {
  1547. var objIsArr = isArray(object), othIsArr = isArray(other), objTag = objIsArr ? arrayTag : getTag(object), othTag = othIsArr ? arrayTag : getTag(other);
  1548. objTag = objTag == argsTag ? objectTag : objTag;
  1549. othTag = othTag == argsTag ? objectTag : othTag;
  1550. var objIsObj = objTag == objectTag, othIsObj = othTag == objectTag, isSameTag = objTag == othTag;
  1551. if (isSameTag && isBuffer(object)) {
  1552. if (!isBuffer(other)) {
  1553. return false;
  1554. }
  1555. objIsArr = true;
  1556. objIsObj = false;
  1557. }
  1558. if (isSameTag && !objIsObj) {
  1559. stack || (stack = new Stack());
  1560. return objIsArr || isTypedArray(object)
  1561. ? equalArrays(object, other, bitmask, customizer, equalFunc, stack)
  1562. : equalByTag(object, other, objTag, bitmask, customizer, equalFunc, stack);
  1563. }
  1564. if (!(bitmask & COMPARE_PARTIAL_FLAG)) {
  1565. var objIsWrapped = objIsObj && hasOwnProperty.call(object, "__wrapped__"), othIsWrapped = othIsObj && hasOwnProperty.call(other, "__wrapped__");
  1566. if (objIsWrapped || othIsWrapped) {
  1567. var objUnwrapped = objIsWrapped ? object.value() : object, othUnwrapped = othIsWrapped ? other.value() : other;
  1568. stack || (stack = new Stack());
  1569. return equalFunc(objUnwrapped, othUnwrapped, bitmask, customizer, stack);
  1570. }
  1571. }
  1572. if (!isSameTag) {
  1573. return false;
  1574. }
  1575. stack || (stack = new Stack());
  1576. return equalObjects(object, other, bitmask, customizer, equalFunc, stack);
  1577. }
  1578. /**
  1579. * The base implementation of `_.isMatch` without support for iteratee shorthands.
  1580. *
  1581. * @private
  1582. * @param {Object} object The object to inspect.
  1583. * @param {Object} source The object of property values to match.
  1584. * @param {Array} matchData The property names, values, and compare flags to match.
  1585. * @param {Function} [customizer] The function to customize comparisons.
  1586. * @returns {boolean} Returns `true` if `object` is a match, else `false`.
  1587. */
  1588. function baseIsMatch(object, source, matchData, customizer) {
  1589. var index = matchData.length, length = index, noCustomizer = !customizer;
  1590. if (object == null) {
  1591. return !length;
  1592. }
  1593. object = Object(object);
  1594. while (index--) {
  1595. var data = matchData[index];
  1596. if (noCustomizer && data[2]
  1597. ? data[1] !== object[data[0]]
  1598. : !(data[0] in object)) {
  1599. return false;
  1600. }
  1601. }
  1602. while (++index < length) {
  1603. data = matchData[index];
  1604. var key = data[0], objValue = object[key], srcValue = data[1];
  1605. if (noCustomizer && data[2]) {
  1606. if (objValue === undefined && !(key in object)) {
  1607. return false;
  1608. }
  1609. }
  1610. else {
  1611. var stack = new Stack();
  1612. if (customizer) {
  1613. var result = customizer(objValue, srcValue, key, object, source, stack);
  1614. }
  1615. if (!(result === undefined
  1616. ? baseIsEqual(srcValue, objValue, COMPARE_PARTIAL_FLAG | COMPARE_UNORDERED_FLAG, customizer, stack)
  1617. : result)) {
  1618. return false;
  1619. }
  1620. }
  1621. }
  1622. return true;
  1623. }
  1624. /**
  1625. * The base implementation of `_.isNative` without bad shim checks.
  1626. *
  1627. * @private
  1628. * @param {*} value The value to check.
  1629. * @returns {boolean} Returns `true` if `value` is a native function,
  1630. * else `false`.
  1631. */
  1632. function baseIsNative(value) {
  1633. if (!isObject(value) || isMasked(value)) {
  1634. return false;
  1635. }
  1636. var pattern = isFunction(value) ? reIsNative : reIsHostCtor;
  1637. return pattern.test(toSource(value));
  1638. }
  1639. /**
  1640. * The base implementation of `_.isTypedArray` without Node.js optimizations.
  1641. *
  1642. * @private
  1643. * @param {*} value The value to check.
  1644. * @returns {boolean} Returns `true` if `value` is a typed array, else `false`.
  1645. */
  1646. function baseIsTypedArray(value) {
  1647. return (isObjectLike(value) &&
  1648. isLength(value.length) &&
  1649. !!typedArrayTags[baseGetTag(value)]);
  1650. }
  1651. /**
  1652. * The base implementation of `_.iteratee`.
  1653. *
  1654. * @private
  1655. * @param {*} [value=_.identity] The value to convert to an iteratee.
  1656. * @returns {Function} Returns the iteratee.
  1657. */
  1658. function baseIteratee(value) {
  1659. // Don't store the `typeof` result in a variable to avoid a JIT bug in Safari 9.
  1660. // See https://bugs.webkit.org/show_bug.cgi?id=156034 for more details.
  1661. if (typeof value == "function") {
  1662. return value;
  1663. }
  1664. if (value == null) {
  1665. return identity;
  1666. }
  1667. if (typeof value == "object") {
  1668. return isArray(value)
  1669. ? baseMatchesProperty(value[0], value[1])
  1670. : baseMatches(value);
  1671. }
  1672. return property(value);
  1673. }
  1674. /**
  1675. * The base implementation of `_.keys` which doesn't treat sparse arrays as dense.
  1676. *
  1677. * @private
  1678. * @param {Object} object The object to query.
  1679. * @returns {Array} Returns the array of property names.
  1680. */
  1681. function baseKeys(object) {
  1682. if (!isPrototype(object)) {
  1683. return nativeKeys(object);
  1684. }
  1685. var result = [];
  1686. for (var key in Object(object)) {
  1687. if (hasOwnProperty.call(object, key) && key != "constructor") {
  1688. result.push(key);
  1689. }
  1690. }
  1691. return result;
  1692. }
  1693. /**
  1694. * The base implementation of `_.keysIn` which doesn't treat sparse arrays as dense.
  1695. *
  1696. * @private
  1697. * @param {Object} object The object to query.
  1698. * @returns {Array} Returns the array of property names.
  1699. */
  1700. function baseKeysIn(object) {
  1701. if (!isObject(object)) {
  1702. return nativeKeysIn(object);
  1703. }
  1704. var isProto = isPrototype(object), result = [];
  1705. for (var key in object) {
  1706. if (!(key == "constructor" &&
  1707. (isProto || !hasOwnProperty.call(object, key)))) {
  1708. result.push(key);
  1709. }
  1710. }
  1711. return result;
  1712. }
  1713. /**
  1714. * The base implementation of `_.matches` which doesn't clone `source`.
  1715. *
  1716. * @private
  1717. * @param {Object} source The object of property values to match.
  1718. * @returns {Function} Returns the new spec function.
  1719. */
  1720. function baseMatches(source) {
  1721. var matchData = getMatchData(source);
  1722. if (matchData.length == 1 && matchData[0][2]) {
  1723. return matchesStrictComparable(matchData[0][0], matchData[0][1]);
  1724. }
  1725. return function (object) {
  1726. return object === source || baseIsMatch(object, source, matchData);
  1727. };
  1728. }
  1729. /**
  1730. * The base implementation of `_.matchesProperty` which doesn't clone `srcValue`.
  1731. *
  1732. * @private
  1733. * @param {string} path The path of the property to get.
  1734. * @param {*} srcValue The value to match.
  1735. * @returns {Function} Returns the new spec function.
  1736. */
  1737. function baseMatchesProperty(path, srcValue) {
  1738. if (isKey(path) && isStrictComparable(srcValue)) {
  1739. return matchesStrictComparable(toKey(path), srcValue);
  1740. }
  1741. return function (object) {
  1742. var objValue = get(object, path);
  1743. return objValue === undefined && objValue === srcValue
  1744. ? hasIn(object, path)
  1745. : baseIsEqual(srcValue, objValue, COMPARE_PARTIAL_FLAG | COMPARE_UNORDERED_FLAG);
  1746. };
  1747. }
  1748. /**
  1749. * The base implementation of `_.merge` without support for multiple sources.
  1750. *
  1751. * @private
  1752. * @param {Object} object The destination object.
  1753. * @param {Object} source The source object.
  1754. * @param {number} srcIndex The index of `source`.
  1755. * @param {Function} [customizer] The function to customize merged values.
  1756. * @param {Object} [stack] Tracks traversed source values and their merged
  1757. * counterparts.
  1758. */
  1759. function baseMerge(object, source, srcIndex, customizer, stack) {
  1760. if (object === source) {
  1761. return;
  1762. }
  1763. baseFor(source, function (srcValue, key) {
  1764. if (isObject(srcValue)) {
  1765. stack || (stack = new Stack());
  1766. baseMergeDeep(object, source, key, srcIndex, baseMerge, customizer, stack);
  1767. }
  1768. else {
  1769. var newValue = customizer
  1770. ? customizer(object[key], srcValue, key + "", object, source, stack)
  1771. : undefined;
  1772. if (newValue === undefined) {
  1773. newValue = srcValue;
  1774. }
  1775. assignMergeValue(object, key, newValue);
  1776. }
  1777. }, keysIn);
  1778. }
  1779. /**
  1780. * A specialized version of `baseMerge` for arrays and objects which performs
  1781. * deep merges and tracks traversed objects enabling objects with circular
  1782. * references to be merged.
  1783. *
  1784. * @private
  1785. * @param {Object} object The destination object.
  1786. * @param {Object} source The source object.
  1787. * @param {string} key The key of the value to merge.
  1788. * @param {number} srcIndex The index of `source`.
  1789. * @param {Function} mergeFunc The function to merge values.
  1790. * @param {Function} [customizer] The function to customize assigned values.
  1791. * @param {Object} [stack] Tracks traversed source values and their merged
  1792. * counterparts.
  1793. */
  1794. function baseMergeDeep(object, source, key, srcIndex, mergeFunc, customizer, stack) {
  1795. var objValue = object[key], srcValue = source[key], stacked = stack.get(srcValue);
  1796. if (stacked) {
  1797. assignMergeValue(object, key, stacked);
  1798. return;
  1799. }
  1800. var newValue = customizer
  1801. ? customizer(objValue, srcValue, key + "", object, source, stack)
  1802. : undefined;
  1803. var isCommon = newValue === undefined;
  1804. if (isCommon) {
  1805. var isArr = isArray(srcValue), isBuff = !isArr && isBuffer(srcValue), isTyped = !isArr && !isBuff && isTypedArray(srcValue);
  1806. newValue = srcValue;
  1807. if (isArr || isBuff || isTyped) {
  1808. if (isArray(objValue)) {
  1809. newValue = objValue;
  1810. }
  1811. else if (isArrayLikeObject(objValue)) {
  1812. newValue = copyArray(objValue);
  1813. }
  1814. else if (isBuff) {
  1815. isCommon = false;
  1816. newValue = cloneBuffer(srcValue, true);
  1817. }
  1818. else if (isTyped) {
  1819. isCommon = false;
  1820. newValue = cloneTypedArray(srcValue, true);
  1821. }
  1822. else {
  1823. newValue = [];
  1824. }
  1825. }
  1826. else if (isPlainObject(srcValue) || isArguments(srcValue)) {
  1827. newValue = objValue;
  1828. if (isArguments(objValue)) {
  1829. newValue = toPlainObject(objValue);
  1830. }
  1831. else if (!isObject(objValue) ||
  1832. (srcIndex && isFunction(objValue))) {
  1833. newValue = initCloneObject(srcValue);
  1834. }
  1835. }
  1836. else {
  1837. isCommon = false;
  1838. }
  1839. }
  1840. if (isCommon) {
  1841. // Recursively merge objects and arrays (susceptible to call stack limits).
  1842. stack.set(srcValue, newValue);
  1843. mergeFunc(newValue, srcValue, srcIndex, customizer, stack);
  1844. stack["delete"](srcValue);
  1845. }
  1846. assignMergeValue(object, key, newValue);
  1847. }
  1848. /**
  1849. * A specialized version of `baseProperty` which supports deep paths.
  1850. *
  1851. * @private
  1852. * @param {Array|string} path The path of the property to get.
  1853. * @returns {Function} Returns the new accessor function.
  1854. */
  1855. function basePropertyDeep(path) {
  1856. return function (object) {
  1857. return baseGet(object, path);
  1858. };
  1859. }
  1860. /**
  1861. * The base implementation of `_.rest` which doesn't validate or coerce arguments.
  1862. *
  1863. * @private
  1864. * @param {Function} func The function to apply a rest parameter to.
  1865. * @param {number} [start=func.length-1] The start position of the rest parameter.
  1866. * @returns {Function} Returns the new function.
  1867. */
  1868. function baseRest(func, start) {
  1869. return setToString(overRest(func, start, identity), func + "");
  1870. }
  1871. /**
  1872. * The base implementation of `_.set`.
  1873. *
  1874. * @private
  1875. * @param {Object} object The object to modify.
  1876. * @param {Array|string} path The path of the property to set.
  1877. * @param {*} value The value to set.
  1878. * @param {Function} [customizer] The function to customize path creation.
  1879. * @returns {Object} Returns `object`.
  1880. */
  1881. function baseSet(object, path, value, customizer) {
  1882. if (!isObject(object)) {
  1883. return object;
  1884. }
  1885. path = castPath(path, object);
  1886. var index = -1, length = path.length, lastIndex = length - 1, nested = object;
  1887. while (nested != null && ++index < length) {
  1888. var key = toKey(path[index]), newValue = value;
  1889. if (index != lastIndex) {
  1890. var objValue = nested[key];
  1891. newValue = customizer
  1892. ? customizer(objValue, key, nested)
  1893. : undefined;
  1894. if (newValue === undefined) {
  1895. newValue = isObject(objValue)
  1896. ? objValue
  1897. : isIndex(path[index + 1]) ? [] : {};
  1898. }
  1899. }
  1900. assignValue(nested, key, newValue);
  1901. nested = nested[key];
  1902. }
  1903. return object;
  1904. }
  1905. /**
  1906. * The base implementation of `setToString` without support for hot loop shorting.
  1907. *
  1908. * @private
  1909. * @param {Function} func The function to modify.
  1910. * @param {Function} string The `toString` result.
  1911. * @returns {Function} Returns `func`.
  1912. */
  1913. var baseSetToString = !defineProperty
  1914. ? identity
  1915. : function (func, string) {
  1916. return defineProperty(func, "toString", {
  1917. configurable: true,
  1918. enumerable: false,
  1919. value: constant(string),
  1920. writable: true
  1921. });
  1922. };
  1923. /**
  1924. * The base implementation of `_.toString` which doesn't convert nullish
  1925. * values to empty strings.
  1926. *
  1927. * @private
  1928. * @param {*} value The value to process.
  1929. * @returns {string} Returns the string.
  1930. */
  1931. function baseToString(value) {
  1932. // Exit early for strings to avoid a performance hit in some environments.
  1933. if (typeof value == "string") {
  1934. return value;
  1935. }
  1936. if (isArray(value)) {
  1937. // Recursively convert values (susceptible to call stack limits).
  1938. return arrayMap(value, baseToString) + "";
  1939. }
  1940. if (isSymbol(value)) {
  1941. return symbolToString ? symbolToString.call(value) : "";
  1942. }
  1943. var result = value + "";
  1944. return result == "0" && 1 / value == -INFINITY ? "-0" : result;
  1945. }
  1946. /**
  1947. * The base implementation of `_.uniqBy` without support for iteratee shorthands.
  1948. *
  1949. * @private
  1950. * @param {Array} array The array to inspect.
  1951. * @param {Function} [iteratee] The iteratee invoked per element.
  1952. * @param {Function} [comparator] The comparator invoked per element.
  1953. * @returns {Array} Returns the new duplicate free array.
  1954. */
  1955. function baseUniq(array, iteratee, comparator) {
  1956. var index = -1, includes = arrayIncludes, length = array.length, isCommon = true, result = [], seen = result;
  1957. if (comparator) {
  1958. isCommon = false;
  1959. includes = arrayIncludesWith;
  1960. }
  1961. else if (length >= LARGE_ARRAY_SIZE) {
  1962. var set = iteratee ? null : createSet(array);
  1963. if (set) {
  1964. return setToArray(set);
  1965. }
  1966. isCommon = false;
  1967. includes = cacheHas;
  1968. seen = new SetCache();
  1969. }
  1970. else {
  1971. seen = iteratee ? [] : result;
  1972. }
  1973. outer: while (++index < length) {
  1974. var value = array[index], computed = iteratee ? iteratee(value) : value;
  1975. value = comparator || value !== 0 ? value : 0;
  1976. if (isCommon && computed === computed) {
  1977. var seenIndex = seen.length;
  1978. while (seenIndex--) {
  1979. if (seen[seenIndex] === computed) {
  1980. continue outer;
  1981. }
  1982. }
  1983. if (iteratee) {
  1984. seen.push(computed);
  1985. }
  1986. result.push(value);
  1987. }
  1988. else if (!includes(seen, computed, comparator)) {
  1989. if (seen !== result) {
  1990. seen.push(computed);
  1991. }
  1992. result.push(value);
  1993. }
  1994. }
  1995. return result;
  1996. }
  1997. /**
  1998. * Casts `value` to a path array if it's not one.
  1999. *
  2000. * @private
  2001. * @param {*} value The value to inspect.
  2002. * @param {Object} [object] The object to query keys on.
  2003. * @returns {Array} Returns the cast property path array.
  2004. */
  2005. function castPath(value, object) {
  2006. if (isArray(value)) {
  2007. return value;
  2008. }
  2009. return isKey(value, object) ? [value] : stringToPath(toString(value));
  2010. }
  2011. /**
  2012. * Creates a clone of `buffer`.
  2013. *
  2014. * @private
  2015. * @param {Buffer} buffer The buffer to clone.
  2016. * @param {boolean} [isDeep] Specify a deep clone.
  2017. * @returns {Buffer} Returns the cloned buffer.
  2018. */
  2019. function cloneBuffer(buffer, isDeep) {
  2020. if (isDeep) {
  2021. return buffer.slice();
  2022. }
  2023. var length = buffer.length, result = allocUnsafe
  2024. ? allocUnsafe(length)
  2025. : new buffer.constructor(length);
  2026. buffer.copy(result);
  2027. return result;
  2028. }
  2029. /**
  2030. * Creates a clone of `arrayBuffer`.
  2031. *
  2032. * @private
  2033. * @param {ArrayBuffer} arrayBuffer The array buffer to clone.
  2034. * @returns {ArrayBuffer} Returns the cloned array buffer.
  2035. */
  2036. function cloneArrayBuffer(arrayBuffer) {
  2037. var result = new arrayBuffer.constructor(arrayBuffer.byteLength);
  2038. new Uint8Array(result).set(new Uint8Array(arrayBuffer));
  2039. return result;
  2040. }
  2041. /**
  2042. * Creates a clone of `dataView`.
  2043. *
  2044. * @private
  2045. * @param {Object} dataView The data view to clone.
  2046. * @param {boolean} [isDeep] Specify a deep clone.
  2047. * @returns {Object} Returns the cloned data view.
  2048. */
  2049. function cloneDataView(dataView, isDeep) {
  2050. var buffer = isDeep
  2051. ? cloneArrayBuffer(dataView.buffer)
  2052. : dataView.buffer;
  2053. return new dataView.constructor(buffer, dataView.byteOffset, dataView.byteLength);
  2054. }
  2055. /**
  2056. * Creates a clone of `map`.
  2057. *
  2058. * @private
  2059. * @param {Object} map The map to clone.
  2060. * @param {Function} cloneFunc The function to clone values.
  2061. * @param {boolean} [isDeep] Specify a deep clone.
  2062. * @returns {Object} Returns the cloned map.
  2063. */
  2064. function cloneMap(map, isDeep, cloneFunc) {
  2065. var array = isDeep
  2066. ? cloneFunc(mapToArray(map), CLONE_DEEP_FLAG)
  2067. : mapToArray(map);
  2068. return arrayReduce(array, addMapEntry, new map.constructor());
  2069. }
  2070. /**
  2071. * Creates a clone of `regexp`.
  2072. *
  2073. * @private
  2074. * @param {Object} regexp The regexp to clone.
  2075. * @returns {Object} Returns the cloned regexp.
  2076. */
  2077. function cloneRegExp(regexp) {
  2078. var result = new regexp.constructor(regexp.source, reFlags.exec(regexp));
  2079. result.lastIndex = regexp.lastIndex;
  2080. return result;
  2081. }
  2082. /**
  2083. * Creates a clone of `set`.
  2084. *
  2085. * @private
  2086. * @param {Object} set The set to clone.
  2087. * @param {Function} cloneFunc The function to clone values.
  2088. * @param {boolean} [isDeep] Specify a deep clone.
  2089. * @returns {Object} Returns the cloned set.
  2090. */
  2091. function cloneSet(set, isDeep, cloneFunc) {
  2092. var array = isDeep
  2093. ? cloneFunc(setToArray(set), CLONE_DEEP_FLAG)
  2094. : setToArray(set);
  2095. return arrayReduce(array, addSetEntry, new set.constructor());
  2096. }
  2097. /**
  2098. * Creates a clone of the `symbol` object.
  2099. *
  2100. * @private
  2101. * @param {Object} symbol The symbol object to clone.
  2102. * @returns {Object} Returns the cloned symbol object.
  2103. */
  2104. function cloneSymbol(symbol) {
  2105. return symbolValueOf ? Object(symbolValueOf.call(symbol)) : {};
  2106. }
  2107. /**
  2108. * Creates a clone of `typedArray`.
  2109. *
  2110. * @private
  2111. * @param {Object} typedArray The typed array to clone.
  2112. * @param {boolean} [isDeep] Specify a deep clone.
  2113. * @returns {Object} Returns the cloned typed array.
  2114. */
  2115. function cloneTypedArray(typedArray, isDeep) {
  2116. var buffer = isDeep
  2117. ? cloneArrayBuffer(typedArray.buffer)
  2118. : typedArray.buffer;
  2119. return new typedArray.constructor(buffer, typedArray.byteOffset, typedArray.length);
  2120. }
  2121. /**
  2122. * Copies the values of `source` to `array`.
  2123. *
  2124. * @private
  2125. * @param {Array} source The array to copy values from.
  2126. * @param {Array} [array=[]] The array to copy values to.
  2127. * @returns {Array} Returns `array`.
  2128. */
  2129. function copyArray(source, array) {
  2130. var index = -1, length = source.length;
  2131. array || (array = Array(length));
  2132. while (++index < length) {
  2133. array[index] = source[index];
  2134. }
  2135. return array;
  2136. }
  2137. /**
  2138. * Copies properties of `source` to `object`.
  2139. *
  2140. * @private
  2141. * @param {Object} source The object to copy properties from.
  2142. * @param {Array} props The property identifiers to copy.
  2143. * @param {Object} [object={}] The object to copy properties to.
  2144. * @param {Function} [customizer] The function to customize copied values.
  2145. * @returns {Object} Returns `object`.
  2146. */
  2147. function copyObject(source, props, object, customizer) {
  2148. var isNew = !object;
  2149. object || (object = {});
  2150. var index = -1, length = props.length;
  2151. while (++index < length) {
  2152. var key = props[index];
  2153. var newValue = customizer
  2154. ? customizer(object[key], source[key], key, object, source)
  2155. : undefined;
  2156. if (newValue === undefined) {
  2157. newValue = source[key];
  2158. }
  2159. if (isNew) {
  2160. baseAssignValue(object, key, newValue);
  2161. }
  2162. else {
  2163. assignValue(object, key, newValue);
  2164. }
  2165. }
  2166. return object;
  2167. }
  2168. /**
  2169. * Copies own symbols of `source` to `object`.
  2170. *
  2171. * @private
  2172. * @param {Object} source The object to copy symbols from.
  2173. * @param {Object} [object={}] The object to copy symbols to.
  2174. * @returns {Object} Returns `object`.
  2175. */
  2176. function copySymbols(source, object) {
  2177. return copyObject(source, getSymbols(source), object);
  2178. }
  2179. /**
  2180. * Copies own and inherited symbols of `source` to `object`.
  2181. *
  2182. * @private
  2183. * @param {Object} source The object to copy symbols from.
  2184. * @param {Object} [object={}] The object to copy symbols to.
  2185. * @returns {Object} Returns `object`.
  2186. */
  2187. function copySymbolsIn(source, object) {
  2188. return copyObject(source, getSymbolsIn(source), object);
  2189. }
  2190. /**
  2191. * Creates a function like `_.assign`.
  2192. *
  2193. * @private
  2194. * @param {Function} assigner The function to assign values.
  2195. * @returns {Function} Returns the new assigner function.
  2196. */
  2197. function createAssigner(assigner) {
  2198. return baseRest(function (object, sources) {
  2199. var index = -1, length = sources.length, customizer = length > 1 ? sources[length - 1] : undefined, guard = length > 2 ? sources[2] : undefined;
  2200. customizer =
  2201. assigner.length > 3 && typeof customizer == "function"
  2202. ? (length--, customizer)
  2203. : undefined;
  2204. if (guard && isIterateeCall(sources[0], sources[1], guard)) {
  2205. customizer = length < 3 ? undefined : customizer;
  2206. length = 1;
  2207. }
  2208. object = Object(object);
  2209. while (++index < length) {
  2210. var source = sources[index];
  2211. if (source) {
  2212. assigner(object, source, index, customizer);
  2213. }
  2214. }
  2215. return object;
  2216. });
  2217. }
  2218. /**
  2219. * Creates a `baseEach` or `baseEachRight` function.
  2220. *
  2221. * @private
  2222. * @param {Function} eachFunc The function to iterate over a collection.
  2223. * @param {boolean} [fromRight] Specify iterating from right to left.
  2224. * @returns {Function} Returns the new base function.
  2225. */
  2226. function createBaseEach(eachFunc, fromRight) {
  2227. return function (collection, iteratee) {
  2228. if (collection == null) {
  2229. return collection;
  2230. }
  2231. if (!isArrayLike(collection)) {
  2232. return eachFunc(collection, iteratee);
  2233. }
  2234. var length = collection.length, index = fromRight ? length : -1, iterable = Object(collection);
  2235. while (fromRight ? index-- : ++index < length) {
  2236. if (iteratee(iterable[index], index, iterable) === false) {
  2237. break;
  2238. }
  2239. }
  2240. return collection;
  2241. };
  2242. }
  2243. /**
  2244. * Creates a base function for methods like `_.forIn` and `_.forOwn`.
  2245. *
  2246. * @private
  2247. * @param {boolean} [fromRight] Specify iterating from right to left.
  2248. * @returns {Function} Returns the new base function.
  2249. */
  2250. function createBaseFor(fromRight) {
  2251. return function (object, iteratee, keysFunc) {
  2252. var index = -1, iterable = Object(object), props = keysFunc(object), length = props.length;
  2253. while (length--) {
  2254. var key = props[fromRight ? length : ++index];
  2255. if (iteratee(iterable[key], key, iterable) === false) {
  2256. break;
  2257. }
  2258. }
  2259. return object;
  2260. };
  2261. }
  2262. /**
  2263. * Creates a set object of `values`.
  2264. *
  2265. * @private
  2266. * @param {Array} values The values to add to the set.
  2267. * @returns {Object} Returns the new set.
  2268. */
  2269. var createSet = !(Set && 1 / setToArray(new Set([, -0]))[1] == INFINITY)
  2270. ? noop
  2271. : function (values) {
  2272. return new Set(values);
  2273. };
  2274. /**
  2275. * A specialized version of `baseIsEqualDeep` for arrays with support for
  2276. * partial deep comparisons.
  2277. *
  2278. * @private
  2279. * @param {Array} array The array to compare.
  2280. * @param {Array} other The other array to compare.
  2281. * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.
  2282. * @param {Function} customizer The function to customize comparisons.
  2283. * @param {Function} equalFunc The function to determine equivalents of values.
  2284. * @param {Object} stack Tracks traversed `array` and `other` objects.
  2285. * @returns {boolean} Returns `true` if the arrays are equivalent, else `false`.
  2286. */
  2287. function equalArrays(array, other, bitmask, customizer, equalFunc, stack) {
  2288. var isPartial = bitmask & COMPARE_PARTIAL_FLAG, arrLength = array.length, othLength = other.length;
  2289. if (arrLength != othLength && !(isPartial && othLength > arrLength)) {
  2290. return false;
  2291. }
  2292. // Assume cyclic values are equal.
  2293. var stacked = stack.get(array);
  2294. if (stacked && stack.get(other)) {
  2295. return stacked == other;
  2296. }
  2297. var index = -1, result = true, seen = bitmask & COMPARE_UNORDERED_FLAG ? new SetCache() : undefined;
  2298. stack.set(array, other);
  2299. stack.set(other, array);
  2300. // Ignore non-index properties.
  2301. while (++index < arrLength) {
  2302. var arrValue = array[index], othValue = other[index];
  2303. if (customizer) {
  2304. var compared = isPartial
  2305. ? customizer(othValue, arrValue, index, other, array, stack)
  2306. : customizer(arrValue, othValue, index, array, other, stack);
  2307. }
  2308. if (compared !== undefined) {
  2309. if (compared) {
  2310. continue;
  2311. }
  2312. result = false;
  2313. break;
  2314. }
  2315. // Recursively compare arrays (susceptible to call stack limits).
  2316. if (seen) {
  2317. if (!arraySome(other, function (othValue, othIndex) {
  2318. if (!cacheHas(seen, othIndex) &&
  2319. (arrValue === othValue ||
  2320. equalFunc(arrValue, othValue, bitmask, customizer, stack))) {
  2321. return seen.push(othIndex);
  2322. }
  2323. })) {
  2324. result = false;
  2325. break;
  2326. }
  2327. }
  2328. else if (!(arrValue === othValue ||
  2329. equalFunc(arrValue, othValue, bitmask, customizer, stack))) {
  2330. result = false;
  2331. break;
  2332. }
  2333. }
  2334. stack["delete"](array);
  2335. stack["delete"](other);
  2336. return result;
  2337. }
  2338. /**
  2339. * A specialized version of `baseIsEqualDeep` for comparing objects of
  2340. * the same `toStringTag`.
  2341. *
  2342. * **Note:** This function only supports comparing values with tags of
  2343. * `Boolean`, `Date`, `Error`, `Number`, `RegExp`, or `String`.
  2344. *
  2345. * @private
  2346. * @param {Object} object The object to compare.
  2347. * @param {Object} other The other object to compare.
  2348. * @param {string} tag The `toStringTag` of the objects to compare.
  2349. * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.
  2350. * @param {Function} customizer The function to customize comparisons.
  2351. * @param {Function} equalFunc The function to determine equivalents of values.
  2352. * @param {Object} stack Tracks traversed `object` and `other` objects.
  2353. * @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
  2354. */
  2355. function equalByTag(object, other, tag, bitmask, customizer, equalFunc, stack) {
  2356. switch (tag) {
  2357. case dataViewTag:
  2358. if (object.byteLength != other.byteLength ||
  2359. object.byteOffset != other.byteOffset) {
  2360. return false;
  2361. }
  2362. object = object.buffer;
  2363. other = other.buffer;
  2364. case arrayBufferTag:
  2365. if (object.byteLength != other.byteLength ||
  2366. !equalFunc(new Uint8Array(object), new Uint8Array(other))) {
  2367. return false;
  2368. }
  2369. return true;
  2370. case boolTag:
  2371. case dateTag:
  2372. case numberTag:
  2373. // Coerce booleans to `1` or `0` and dates to milliseconds.
  2374. // Invalid dates are coerced to `NaN`.
  2375. return eq(+object, +other);
  2376. case errorTag:
  2377. return (object.name == other.name && object.message == other.message);
  2378. case regexpTag:
  2379. case stringTag:
  2380. // Coerce regexes to strings and treat strings, primitives and objects,
  2381. // as equal. See http://www.ecma-international.org/ecma-262/7.0/#sec-regexp.prototype.tostring
  2382. // for more details.
  2383. return object == other + "";
  2384. case mapTag:
  2385. var convert = mapToArray;
  2386. case setTag:
  2387. var isPartial = bitmask & COMPARE_PARTIAL_FLAG;
  2388. convert || (convert = setToArray);
  2389. if (object.size != other.size && !isPartial) {
  2390. return false;
  2391. }
  2392. // Assume cyclic values are equal.
  2393. var stacked = stack.get(object);
  2394. if (stacked) {
  2395. return stacked == other;
  2396. }
  2397. bitmask |= COMPARE_UNORDERED_FLAG;
  2398. // Recursively compare objects (susceptible to call stack limits).
  2399. stack.set(object, other);
  2400. var result = equalArrays(convert(object), convert(other), bitmask, customizer, equalFunc, stack);
  2401. stack["delete"](object);
  2402. return result;
  2403. case symbolTag:
  2404. if (symbolValueOf) {
  2405. return (symbolValueOf.call(object) == symbolValueOf.call(other));
  2406. }
  2407. }
  2408. return false;
  2409. }
  2410. /**
  2411. * A specialized version of `baseIsEqualDeep` for objects with support for
  2412. * partial deep comparisons.
  2413. *
  2414. * @private
  2415. * @param {Object} object The object to compare.
  2416. * @param {Object} other The other object to compare.
  2417. * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.
  2418. * @param {Function} customizer The function to customize comparisons.
  2419. * @param {Function} equalFunc The function to determine equivalents of values.
  2420. * @param {Object} stack Tracks traversed `object` and `other` objects.
  2421. * @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
  2422. */
  2423. function equalObjects(object, other, bitmask, customizer, equalFunc, stack) {
  2424. var isPartial = bitmask & COMPARE_PARTIAL_FLAG, objProps = getAllKeys(object), objLength = objProps.length, othProps = getAllKeys(other), othLength = othProps.length;
  2425. if (objLength != othLength && !isPartial) {
  2426. return false;
  2427. }
  2428. var index = objLength;
  2429. while (index--) {
  2430. var key = objProps[index];
  2431. if (!(isPartial ? key in other : hasOwnProperty.call(other, key))) {
  2432. return false;
  2433. }
  2434. }
  2435. // Assume cyclic values are equal.
  2436. var stacked = stack.get(object);
  2437. if (stacked && stack.get(other)) {
  2438. return stacked == other;
  2439. }
  2440. var result = true;
  2441. stack.set(object, other);
  2442. stack.set(other, object);
  2443. var skipCtor = isPartial;
  2444. while (++index < objLength) {
  2445. key = objProps[index];
  2446. var objValue = object[key], othValue = other[key];
  2447. if (customizer) {
  2448. var compared = isPartial
  2449. ? customizer(othValue, objValue, key, other, object, stack)
  2450. : customizer(objValue, othValue, key, object, other, stack);
  2451. }
  2452. // Recursively compare objects (susceptible to call stack limits).
  2453. if (!(compared === undefined
  2454. ? objValue === othValue ||
  2455. equalFunc(objValue, othValue, bitmask, customizer, stack)
  2456. : compared)) {
  2457. result = false;
  2458. break;
  2459. }
  2460. skipCtor || (skipCtor = key == "constructor");
  2461. }
  2462. if (result && !skipCtor) {
  2463. var objCtor = object.constructor, othCtor = other.constructor;
  2464. // Non `Object` object instances with different constructors are not equal.
  2465. if (objCtor != othCtor &&
  2466. ("constructor" in object && "constructor" in other) &&
  2467. !(typeof objCtor == "function" &&
  2468. objCtor instanceof objCtor &&
  2469. typeof othCtor == "function" &&
  2470. othCtor instanceof othCtor)) {
  2471. result = false;
  2472. }
  2473. }
  2474. stack["delete"](object);
  2475. stack["delete"](other);
  2476. return result;
  2477. }
  2478. /**
  2479. * Creates an array of own enumerable property names and symbols of `object`.
  2480. *
  2481. * @private
  2482. * @param {Object} object The object to query.
  2483. * @returns {Array} Returns the array of property names and symbols.
  2484. */
  2485. function getAllKeys(object) {
  2486. return baseGetAllKeys(object, keys, getSymbols);
  2487. }
  2488. /**
  2489. * Creates an array of own and inherited enumerable property names and
  2490. * symbols of `object`.
  2491. *
  2492. * @private
  2493. * @param {Object} object The object to query.
  2494. * @returns {Array} Returns the array of property names and symbols.
  2495. */
  2496. function getAllKeysIn(object) {
  2497. return baseGetAllKeys(object, keysIn, getSymbolsIn);
  2498. }
  2499. /**
  2500. * Gets the appropriate "iteratee" function. If `_.iteratee` is customized,
  2501. * this function returns the custom method, otherwise it returns `baseIteratee`.
  2502. * If arguments are provided, the chosen function is invoked with them and
  2503. * its result is returned.
  2504. *
  2505. * @private
  2506. * @param {*} [value] The value to convert to an iteratee.
  2507. * @param {number} [arity] The arity of the created iteratee.
  2508. * @returns {Function} Returns the chosen function or its result.
  2509. */
  2510. function getIteratee() {
  2511. var result = lodash.iteratee || iteratee;
  2512. result = result === iteratee ? baseIteratee : result;
  2513. return arguments.length ? result(arguments[0], arguments[1]) : result;
  2514. }
  2515. /**
  2516. * Gets the data for `map`.
  2517. *
  2518. * @private
  2519. * @param {Object} map The map to query.
  2520. * @param {string} key The reference key.
  2521. * @returns {*} Returns the map data.
  2522. */
  2523. function getMapData(map, key) {
  2524. var data = map.__data__;
  2525. return isKeyable(key)
  2526. ? data[typeof key == "string" ? "string" : "hash"]
  2527. : data.map;
  2528. }
  2529. /**
  2530. * Gets the property names, values, and compare flags of `object`.
  2531. *
  2532. * @private
  2533. * @param {Object} object The object to query.
  2534. * @returns {Array} Returns the match data of `object`.
  2535. */
  2536. function getMatchData(object) {
  2537. var result = keys(object), length = result.length;
  2538. while (length--) {
  2539. var key = result[length], value = object[key];
  2540. result[length] = [key, value, isStrictComparable(value)];
  2541. }
  2542. return result;
  2543. }
  2544. /**
  2545. * Gets the native function at `key` of `object`.
  2546. *
  2547. * @private
  2548. * @param {Object} object The object to query.
  2549. * @param {string} key The key of the method to get.
  2550. * @returns {*} Returns the function if it's native, else `undefined`.
  2551. */
  2552. function getNative(object, key) {
  2553. var value = getValue(object, key);
  2554. return baseIsNative(value) ? value : undefined;
  2555. }
  2556. /**
  2557. * A specialized version of `baseGetTag` which ignores `Symbol.toStringTag` values.
  2558. *
  2559. * @private
  2560. * @param {*} value The value to query.
  2561. * @returns {string} Returns the raw `toStringTag`.
  2562. */
  2563. function getRawTag(value) {
  2564. var isOwn = hasOwnProperty.call(value, symToStringTag), tag = value[symToStringTag];
  2565. try {
  2566. value[symToStringTag] = undefined;
  2567. var unmasked = true;
  2568. }
  2569. catch (e) { }
  2570. var result = nativeObjectToString.call(value);
  2571. if (unmasked) {
  2572. if (isOwn) {
  2573. value[symToStringTag] = tag;
  2574. }
  2575. else {
  2576. delete value[symToStringTag];
  2577. }
  2578. }
  2579. return result;
  2580. }
  2581. /**
  2582. * Creates an array of the own enumerable symbols of `object`.
  2583. *
  2584. * @private
  2585. * @param {Object} object The object to query.
  2586. * @returns {Array} Returns the array of symbols.
  2587. */
  2588. var getSymbols = !nativeGetSymbols
  2589. ? stubArray
  2590. : function (object) {
  2591. if (object == null) {
  2592. return [];
  2593. }
  2594. object = Object(object);
  2595. return arrayFilter(nativeGetSymbols(object), function (symbol) {
  2596. return propertyIsEnumerable.call(object, symbol);
  2597. });
  2598. };
  2599. /**
  2600. * Creates an array of the own and inherited enumerable symbols of `object`.
  2601. *
  2602. * @private
  2603. * @param {Object} object The object to query.
  2604. * @returns {Array} Returns the array of symbols.
  2605. */
  2606. var getSymbolsIn = !nativeGetSymbols
  2607. ? stubArray
  2608. : function (object) {
  2609. var result = [];
  2610. while (object) {
  2611. arrayPush(result, getSymbols(object));
  2612. object = getPrototype(object);
  2613. }
  2614. return result;
  2615. };
  2616. /**
  2617. * Gets the `toStringTag` of `value`.
  2618. *
  2619. * @private
  2620. * @param {*} value The value to query.
  2621. * @returns {string} Returns the `toStringTag`.
  2622. */
  2623. var getTag = baseGetTag;
  2624. // Fallback for data views, maps, sets, and weak maps in IE 11 and promises in Node.js < 6.
  2625. if ((DataView && getTag(new DataView(new ArrayBuffer(1))) != dataViewTag) ||
  2626. (Map && getTag(new Map()) != mapTag) ||
  2627. (Promise && getTag(Promise.resolve()) != promiseTag) ||
  2628. (Set && getTag(new Set()) != setTag) ||
  2629. (WeakMap && getTag(new WeakMap()) != weakMapTag)) {
  2630. getTag = function (value) {
  2631. var result = baseGetTag(value), Ctor = result == objectTag ? value.constructor : undefined, ctorString = Ctor ? toSource(Ctor) : "";
  2632. if (ctorString) {
  2633. switch (ctorString) {
  2634. case dataViewCtorString:
  2635. return dataViewTag;
  2636. case mapCtorString:
  2637. return mapTag;
  2638. case promiseCtorString:
  2639. return promiseTag;
  2640. case setCtorString:
  2641. return setTag;
  2642. case weakMapCtorString:
  2643. return weakMapTag;
  2644. }
  2645. }
  2646. return result;
  2647. };
  2648. }
  2649. /**
  2650. * Checks if `path` exists on `object`.
  2651. *
  2652. * @private
  2653. * @param {Object} object The object to query.
  2654. * @param {Array|string} path The path to check.
  2655. * @param {Function} hasFunc The function to check properties.
  2656. * @returns {boolean} Returns `true` if `path` exists, else `false`.
  2657. */
  2658. function hasPath(object, path, hasFunc) {
  2659. path = castPath(path, object);
  2660. var index = -1, length = path.length, result = false;
  2661. while (++index < length) {
  2662. var key = toKey(path[index]);
  2663. if (!(result = object != null && hasFunc(object, key))) {
  2664. break;
  2665. }
  2666. object = object[key];
  2667. }
  2668. if (result || ++index != length) {
  2669. return result;
  2670. }
  2671. length = object == null ? 0 : object.length;
  2672. return (!!length &&
  2673. isLength(length) &&
  2674. isIndex(key, length) &&
  2675. (isArray(object) || isArguments(object)));
  2676. }
  2677. /**
  2678. * Initializes an array clone.
  2679. *
  2680. * @private
  2681. * @param {Array} array The array to clone.
  2682. * @returns {Array} Returns the initialized clone.
  2683. */
  2684. function initCloneArray(array) {
  2685. var length = array.length, result = array.constructor(length);
  2686. // Add properties assigned by `RegExp#exec`.
  2687. if (length &&
  2688. typeof array[0] == "string" &&
  2689. hasOwnProperty.call(array, "index")) {
  2690. result.index = array.index;
  2691. result.input = array.input;
  2692. }
  2693. return result;
  2694. }
  2695. /**
  2696. * Initializes an object clone.
  2697. *
  2698. * @private
  2699. * @param {Object} object The object to clone.
  2700. * @returns {Object} Returns the initialized clone.
  2701. */
  2702. function initCloneObject(object) {
  2703. return typeof object.constructor == "function" && !isPrototype(object)
  2704. ? baseCreate(getPrototype(object))
  2705. : {};
  2706. }
  2707. /**
  2708. * Initializes an object clone based on its `toStringTag`.
  2709. *
  2710. * **Note:** This function only supports cloning values with tags of
  2711. * `Boolean`, `Date`, `Error`, `Number`, `RegExp`, or `String`.
  2712. *
  2713. * @private
  2714. * @param {Object} object The object to clone.
  2715. * @param {string} tag The `toStringTag` of the object to clone.
  2716. * @param {Function} cloneFunc The function to clone values.
  2717. * @param {boolean} [isDeep] Specify a deep clone.
  2718. * @returns {Object} Returns the initialized clone.
  2719. */
  2720. function initCloneByTag(object, tag, cloneFunc, isDeep) {
  2721. var Ctor = object.constructor;
  2722. switch (tag) {
  2723. case arrayBufferTag:
  2724. return cloneArrayBuffer(object);
  2725. case boolTag:
  2726. case dateTag:
  2727. return new Ctor(+object);
  2728. case dataViewTag:
  2729. return cloneDataView(object, isDeep);
  2730. case float32Tag:
  2731. case float64Tag:
  2732. case int8Tag:
  2733. case int16Tag:
  2734. case int32Tag:
  2735. case uint8Tag:
  2736. case uint8ClampedTag:
  2737. case uint16Tag:
  2738. case uint32Tag:
  2739. return cloneTypedArray(object, isDeep);
  2740. case mapTag:
  2741. return cloneMap(object, isDeep, cloneFunc);
  2742. case numberTag:
  2743. case stringTag:
  2744. return new Ctor(object);
  2745. case regexpTag:
  2746. return cloneRegExp(object);
  2747. case setTag:
  2748. return cloneSet(object, isDeep, cloneFunc);
  2749. case symbolTag:
  2750. return cloneSymbol(object);
  2751. }
  2752. }
  2753. /**
  2754. * Checks if `value` is a flattenable `arguments` object or array.
  2755. *
  2756. * @private
  2757. * @param {*} value The value to check.
  2758. * @returns {boolean} Returns `true` if `value` is flattenable, else `false`.
  2759. */
  2760. function isFlattenable(value) {
  2761. return (isArray(value) ||
  2762. isArguments(value) ||
  2763. !!(spreadableSymbol && value && value[spreadableSymbol]));
  2764. }
  2765. /**
  2766. * Checks if `value` is a valid array-like index.
  2767. *
  2768. * @private
  2769. * @param {*} value The value to check.
  2770. * @param {number} [length=MAX_SAFE_INTEGER] The upper bounds of a valid index.
  2771. * @returns {boolean} Returns `true` if `value` is a valid index, else `false`.
  2772. */
  2773. function isIndex(value, length) {
  2774. length = length == null ? MAX_SAFE_INTEGER : length;
  2775. return (!!length &&
  2776. (typeof value == "number" || reIsUint.test(value)) &&
  2777. (value > -1 && value % 1 == 0 && value < length));
  2778. }
  2779. /**
  2780. * Checks if the given arguments are from an iteratee call.
  2781. *
  2782. * @private
  2783. * @param {*} value The potential iteratee value argument.
  2784. * @param {*} index The potential iteratee index or key argument.
  2785. * @param {*} object The potential iteratee object argument.
  2786. * @returns {boolean} Returns `true` if the arguments are from an iteratee call,
  2787. * else `false`.
  2788. */
  2789. function isIterateeCall(value, index, object) {
  2790. if (!isObject(object)) {
  2791. return false;
  2792. }
  2793. var type = typeof index;
  2794. if (type == "number"
  2795. ? isArrayLike(object) && isIndex(index, object.length)
  2796. : type == "string" && index in object) {
  2797. return eq(object[index], value);
  2798. }
  2799. return false;
  2800. }
  2801. /**
  2802. * Checks if `value` is a property name and not a property path.
  2803. *
  2804. * @private
  2805. * @param {*} value The value to check.
  2806. * @param {Object} [object] The object to query keys on.
  2807. * @returns {boolean} Returns `true` if `value` is a property name, else `false`.
  2808. */
  2809. function isKey(value, object) {
  2810. if (isArray(value)) {
  2811. return false;
  2812. }
  2813. var type = typeof value;
  2814. if (type == "number" ||
  2815. type == "symbol" ||
  2816. type == "boolean" ||
  2817. value == null ||
  2818. isSymbol(value)) {
  2819. return true;
  2820. }
  2821. return (reIsPlainProp.test(value) ||
  2822. !reIsDeepProp.test(value) ||
  2823. (object != null && value in Object(object)));
  2824. }
  2825. /**
  2826. * Checks if `value` is suitable for use as unique object key.
  2827. *
  2828. * @private
  2829. * @param {*} value The value to check.
  2830. * @returns {boolean} Returns `true` if `value` is suitable, else `false`.
  2831. */
  2832. function isKeyable(value) {
  2833. var type = typeof value;
  2834. return type == "string" ||
  2835. type == "number" ||
  2836. type == "symbol" ||
  2837. type == "boolean"
  2838. ? value !== "__proto__"
  2839. : value === null;
  2840. }
  2841. /**
  2842. * Checks if `func` has its source masked.
  2843. *
  2844. * @private
  2845. * @param {Function} func The function to check.
  2846. * @returns {boolean} Returns `true` if `func` is masked, else `false`.
  2847. */
  2848. function isMasked(func) {
  2849. return !!maskSrcKey && maskSrcKey in func;
  2850. }
  2851. /**
  2852. * Checks if `value` is likely a prototype object.
  2853. *
  2854. * @private
  2855. * @param {*} value The value to check.
  2856. * @returns {boolean} Returns `true` if `value` is a prototype, else `false`.
  2857. */
  2858. function isPrototype(value) {
  2859. var Ctor = value && value.constructor, proto = (typeof Ctor == "function" && Ctor.prototype) || objectProto;
  2860. return value === proto;
  2861. }
  2862. /**
  2863. * Checks if `value` is suitable for strict equality comparisons, i.e. `===`.
  2864. *
  2865. * @private
  2866. * @param {*} value The value to check.
  2867. * @returns {boolean} Returns `true` if `value` if suitable for strict
  2868. * equality comparisons, else `false`.
  2869. */
  2870. function isStrictComparable(value) {
  2871. return value === value && !isObject(value);
  2872. }
  2873. /**
  2874. * A specialized version of `matchesProperty` for source values suitable
  2875. * for strict equality comparisons, i.e. `===`.
  2876. *
  2877. * @private
  2878. * @param {string} key The key of the property to get.
  2879. * @param {*} srcValue The value to match.
  2880. * @returns {Function} Returns the new spec function.
  2881. */
  2882. function matchesStrictComparable(key, srcValue) {
  2883. return function (object) {
  2884. if (object == null) {
  2885. return false;
  2886. }
  2887. return (object[key] === srcValue &&
  2888. (srcValue !== undefined || key in Object(object)));
  2889. };
  2890. }
  2891. /**
  2892. * A specialized version of `_.memoize` which clears the memoized function's
  2893. * cache when it exceeds `MAX_MEMOIZE_SIZE`.
  2894. *
  2895. * @private
  2896. * @param {Function} func The function to have its output memoized.
  2897. * @returns {Function} Returns the new memoized function.
  2898. */
  2899. function memoizeCapped(func) {
  2900. var result = memoize(func, function (key) {
  2901. if (cache.size === MAX_MEMOIZE_SIZE) {
  2902. cache.clear();
  2903. }
  2904. return key;
  2905. });
  2906. var cache = result.cache;
  2907. return result;
  2908. }
  2909. /**
  2910. * This function is like
  2911. * [`Object.keys`](http://ecma-international.org/ecma-262/7.0/#sec-object.keys)
  2912. * except that it includes inherited enumerable properties.
  2913. *
  2914. * @private
  2915. * @param {Object} object The object to query.
  2916. * @returns {Array} Returns the array of property names.
  2917. */
  2918. function nativeKeysIn(object) {
  2919. var result = [];
  2920. if (object != null) {
  2921. for (var key in Object(object)) {
  2922. result.push(key);
  2923. }
  2924. }
  2925. return result;
  2926. }
  2927. /**
  2928. * Converts `value` to a string using `Object.prototype.toString`.
  2929. *
  2930. * @private
  2931. * @param {*} value The value to convert.
  2932. * @returns {string} Returns the converted string.
  2933. */
  2934. function objectToString(value) {
  2935. return nativeObjectToString.call(value);
  2936. }
  2937. /**
  2938. * A specialized version of `baseRest` which transforms the rest array.
  2939. *
  2940. * @private
  2941. * @param {Function} func The function to apply a rest parameter to.
  2942. * @param {number} [start=func.length-1] The start position of the rest parameter.
  2943. * @param {Function} transform The rest array transform.
  2944. * @returns {Function} Returns the new function.
  2945. */
  2946. function overRest(func, start, transform) {
  2947. start = nativeMax(start === undefined ? func.length - 1 : start, 0);
  2948. return function () {
  2949. var args = arguments, index = -1, length = nativeMax(args.length - start, 0), array = Array(length);
  2950. while (++index < length) {
  2951. array[index] = args[start + index];
  2952. }
  2953. index = -1;
  2954. var otherArgs = Array(start + 1);
  2955. while (++index < start) {
  2956. otherArgs[index] = args[index];
  2957. }
  2958. otherArgs[start] = transform(array);
  2959. return apply(func, this, otherArgs);
  2960. };
  2961. }
  2962. /**
  2963. * Sets the `toString` method of `func` to return `string`.
  2964. *
  2965. * @private
  2966. * @param {Function} func The function to modify.
  2967. * @param {Function} string The `toString` result.
  2968. * @returns {Function} Returns `func`.
  2969. */
  2970. var setToString = shortOut(baseSetToString);
  2971. /**
  2972. * Creates a function that'll short out and invoke `identity` instead
  2973. * of `func` when it's called `HOT_COUNT` or more times in `HOT_SPAN`
  2974. * milliseconds.
  2975. *
  2976. * @private
  2977. * @param {Function} func The function to restrict.
  2978. * @returns {Function} Returns the new shortable function.
  2979. */
  2980. function shortOut(func) {
  2981. var count = 0, lastCalled = 0;
  2982. return function () {
  2983. var stamp = nativeNow(), remaining = HOT_SPAN - (stamp - lastCalled);
  2984. lastCalled = stamp;
  2985. if (remaining > 0) {
  2986. if (++count >= HOT_COUNT) {
  2987. return arguments[0];
  2988. }
  2989. }
  2990. else {
  2991. count = 0;
  2992. }
  2993. return func.apply(undefined, arguments);
  2994. };
  2995. }
  2996. /**
  2997. * Converts `string` to a property path array.
  2998. *
  2999. * @private
  3000. * @param {string} string The string to convert.
  3001. * @returns {Array} Returns the property path array.
  3002. */
  3003. var stringToPath = memoizeCapped(function (string) {
  3004. var result = [];
  3005. if (reLeadingDot.test(string)) {
  3006. result.push("");
  3007. }
  3008. string.replace(rePropName, function (match, number, quote, string) {
  3009. result.push(quote ? string.replace(reEscapeChar, "$1") : number || match);
  3010. });
  3011. return result;
  3012. });
  3013. /**
  3014. * Converts `value` to a string key if it's not a string or symbol.
  3015. *
  3016. * @private
  3017. * @param {*} value The value to inspect.
  3018. * @returns {string|symbol} Returns the key.
  3019. */
  3020. function toKey(value) {
  3021. if (typeof value == "string" || isSymbol(value)) {
  3022. return value;
  3023. }
  3024. var result = value + "";
  3025. return result == "0" && 1 / value == -INFINITY ? "-0" : result;
  3026. }
  3027. /**
  3028. * Converts `func` to its source code.
  3029. *
  3030. * @private
  3031. * @param {Function} func The function to convert.
  3032. * @returns {string} Returns the source code.
  3033. */
  3034. function toSource(func) {
  3035. if (func != null) {
  3036. try {
  3037. return funcToString.call(func);
  3038. }
  3039. catch (e) { }
  3040. try {
  3041. return func + "";
  3042. }
  3043. catch (e) { }
  3044. }
  3045. return "";
  3046. }
  3047. /*------------------------------------------------------------------------*/
  3048. /**
  3049. * Creates an array of unique values, in order, from all given arrays using
  3050. * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
  3051. * for equality comparisons.
  3052. *
  3053. * @static
  3054. * @memberOf _
  3055. * @since 0.1.0
  3056. * @category Array
  3057. * @param {...Array} [arrays] The arrays to inspect.
  3058. * @returns {Array} Returns the new array of combined values.
  3059. * @example
  3060. *
  3061. * _.union([2], [1, 2]);
  3062. * // => [2, 1]
  3063. */
  3064. var union = baseRest(function (arrays) {
  3065. return baseUniq(baseFlatten(arrays, 1, isArrayLikeObject, true));
  3066. });
  3067. /*------------------------------------------------------------------------*/
  3068. /**
  3069. * Iterates over elements of `collection` and invokes `iteratee` for each element.
  3070. * The iteratee is invoked with three arguments: (value, index|key, collection).
  3071. * Iteratee functions may exit iteration early by explicitly returning `false`.
  3072. *
  3073. * **Note:** As with other "Collections" methods, objects with a "length"
  3074. * property are iterated like arrays. To avoid this behavior use `_.forIn`
  3075. * or `_.forOwn` for object iteration.
  3076. *
  3077. * @static
  3078. * @memberOf _
  3079. * @since 0.1.0
  3080. * @alias each
  3081. * @category Collection
  3082. * @param {Array|Object} collection The collection to iterate over.
  3083. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  3084. * @returns {Array|Object} Returns `collection`.
  3085. * @see _.forEachRight
  3086. * @example
  3087. *
  3088. * _.forEach([1, 2], function(value) {
  3089. * console.log(value);
  3090. * });
  3091. * // => Logs `1` then `2`.
  3092. *
  3093. * _.forEach({ 'a': 1, 'b': 2 }, function(value, key) {
  3094. * console.log(key);
  3095. * });
  3096. * // => Logs 'a' then 'b' (iteration order is not guaranteed).
  3097. */
  3098. function forEach(collection, iteratee) {
  3099. var func = isArray(collection) ? arrayEach : baseEach;
  3100. return func(collection, getIteratee(iteratee, 3));
  3101. }
  3102. /**
  3103. * Checks if `value` is in `collection`. If `collection` is a string, it's
  3104. * checked for a substring of `value`, otherwise
  3105. * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
  3106. * is used for equality comparisons. If `fromIndex` is negative, it's used as
  3107. * the offset from the end of `collection`.
  3108. *
  3109. * @static
  3110. * @memberOf _
  3111. * @since 0.1.0
  3112. * @category Collection
  3113. * @param {Array|Object|string} collection The collection to inspect.
  3114. * @param {*} value The value to search for.
  3115. * @param {number} [fromIndex=0] The index to search from.
  3116. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.reduce`.
  3117. * @returns {boolean} Returns `true` if `value` is found, else `false`.
  3118. * @example
  3119. *
  3120. * _.includes([1, 2, 3], 1);
  3121. * // => true
  3122. *
  3123. * _.includes([1, 2, 3], 1, 2);
  3124. * // => false
  3125. *
  3126. * _.includes({ 'a': 1, 'b': 2 }, 1);
  3127. * // => true
  3128. *
  3129. * _.includes('abcd', 'bc');
  3130. * // => true
  3131. */
  3132. function includes(collection, value, fromIndex, guard) {
  3133. collection = isArrayLike(collection) ? collection : values(collection);
  3134. fromIndex = fromIndex && !guard ? toInteger(fromIndex) : 0;
  3135. var length = collection.length;
  3136. if (fromIndex < 0) {
  3137. fromIndex = nativeMax(length + fromIndex, 0);
  3138. }
  3139. return isString(collection)
  3140. ? fromIndex <= length && collection.indexOf(value, fromIndex) > -1
  3141. : !!length && baseIndexOf(collection, value, fromIndex) > -1;
  3142. }
  3143. /*------------------------------------------------------------------------*/
  3144. /**
  3145. * Creates a function that memoizes the result of `func`. If `resolver` is
  3146. * provided, it determines the cache key for storing the result based on the
  3147. * arguments provided to the memoized function. By default, the first argument
  3148. * provided to the memoized function is used as the map cache key. The `func`
  3149. * is invoked with the `this` binding of the memoized function.
  3150. *
  3151. * **Note:** The cache is exposed as the `cache` property on the memoized
  3152. * function. Its creation may be customized by replacing the `_.memoize.Cache`
  3153. * constructor with one whose instances implement the
  3154. * [`Map`](http://ecma-international.org/ecma-262/7.0/#sec-properties-of-the-map-prototype-object)
  3155. * method interface of `clear`, `delete`, `get`, `has`, and `set`.
  3156. *
  3157. * @static
  3158. * @memberOf _
  3159. * @since 0.1.0
  3160. * @category Function
  3161. * @param {Function} func The function to have its output memoized.
  3162. * @param {Function} [resolver] The function to resolve the cache key.
  3163. * @returns {Function} Returns the new memoized function.
  3164. * @example
  3165. *
  3166. * var object = { 'a': 1, 'b': 2 };
  3167. * var other = { 'c': 3, 'd': 4 };
  3168. *
  3169. * var values = _.memoize(_.values);
  3170. * values(object);
  3171. * // => [1, 2]
  3172. *
  3173. * values(other);
  3174. * // => [3, 4]
  3175. *
  3176. * object.a = 2;
  3177. * values(object);
  3178. * // => [1, 2]
  3179. *
  3180. * // Modify the result cache.
  3181. * values.cache.set(object, ['a', 'b']);
  3182. * values(object);
  3183. * // => ['a', 'b']
  3184. *
  3185. * // Replace `_.memoize.Cache`.
  3186. * _.memoize.Cache = WeakMap;
  3187. */
  3188. function memoize(func, resolver) {
  3189. if (typeof func != "function" ||
  3190. (resolver != null && typeof resolver != "function")) {
  3191. throw new TypeError(FUNC_ERROR_TEXT);
  3192. }
  3193. var memoized = function () {
  3194. var args = arguments, key = resolver ? resolver.apply(this, args) : args[0], cache = memoized.cache;
  3195. if (cache.has(key)) {
  3196. return cache.get(key);
  3197. }
  3198. var result = func.apply(this, args);
  3199. memoized.cache = cache.set(key, result) || cache;
  3200. return result;
  3201. };
  3202. memoized.cache = new (memoize.Cache || MapCache)();
  3203. return memoized;
  3204. }
  3205. // Expose `MapCache`.
  3206. memoize.Cache = MapCache;
  3207. /*------------------------------------------------------------------------*/
  3208. /**
  3209. * Performs a
  3210. * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
  3211. * comparison between two values to determine if they are equivalent.
  3212. *
  3213. * @static
  3214. * @memberOf _
  3215. * @since 4.0.0
  3216. * @category Lang
  3217. * @param {*} value The value to compare.
  3218. * @param {*} other The other value to compare.
  3219. * @returns {boolean} Returns `true` if the values are equivalent, else `false`.
  3220. * @example
  3221. *
  3222. * var object = { 'a': 1 };
  3223. * var other = { 'a': 1 };
  3224. *
  3225. * _.eq(object, object);
  3226. * // => true
  3227. *
  3228. * _.eq(object, other);
  3229. * // => false
  3230. *
  3231. * _.eq('a', 'a');
  3232. * // => true
  3233. *
  3234. * _.eq('a', Object('a'));
  3235. * // => false
  3236. *
  3237. * _.eq(NaN, NaN);
  3238. * // => true
  3239. */
  3240. function eq(value, other) {
  3241. return value === other || (value !== value && other !== other);
  3242. }
  3243. /**
  3244. * Checks if `value` is likely an `arguments` object.
  3245. *
  3246. * @static
  3247. * @memberOf _
  3248. * @since 0.1.0
  3249. * @category Lang
  3250. * @param {*} value The value to check.
  3251. * @returns {boolean} Returns `true` if `value` is an `arguments` object,
  3252. * else `false`.
  3253. * @example
  3254. *
  3255. * _.isArguments(function() { return arguments; }());
  3256. * // => true
  3257. *
  3258. * _.isArguments([1, 2, 3]);
  3259. * // => false
  3260. */
  3261. var isArguments = baseIsArguments((function () {
  3262. return arguments;
  3263. })())
  3264. ? baseIsArguments
  3265. : function (value) {
  3266. return (isObjectLike(value) &&
  3267. hasOwnProperty.call(value, "callee") &&
  3268. !propertyIsEnumerable.call(value, "callee"));
  3269. };
  3270. /**
  3271. * Checks if `value` is classified as an `Array` object.
  3272. *
  3273. * @static
  3274. * @memberOf _
  3275. * @since 0.1.0
  3276. * @category Lang
  3277. * @param {*} value The value to check.
  3278. * @returns {boolean} Returns `true` if `value` is an array, else `false`.
  3279. * @example
  3280. *
  3281. * _.isArray([1, 2, 3]);
  3282. * // => true
  3283. *
  3284. * _.isArray(document.body.children);
  3285. * // => false
  3286. *
  3287. * _.isArray('abc');
  3288. * // => false
  3289. *
  3290. * _.isArray(_.noop);
  3291. * // => false
  3292. */
  3293. var isArray = Array.isArray;
  3294. /**
  3295. * Checks if `value` is array-like. A value is considered array-like if it's
  3296. * not a function and has a `value.length` that's an integer greater than or
  3297. * equal to `0` and less than or equal to `Number.MAX_SAFE_INTEGER`.
  3298. *
  3299. * @static
  3300. * @memberOf _
  3301. * @since 4.0.0
  3302. * @category Lang
  3303. * @param {*} value The value to check.
  3304. * @returns {boolean} Returns `true` if `value` is array-like, else `false`.
  3305. * @example
  3306. *
  3307. * _.isArrayLike([1, 2, 3]);
  3308. * // => true
  3309. *
  3310. * _.isArrayLike(document.body.children);
  3311. * // => true
  3312. *
  3313. * _.isArrayLike('abc');
  3314. * // => true
  3315. *
  3316. * _.isArrayLike(_.noop);
  3317. * // => false
  3318. */
  3319. function isArrayLike(value) {
  3320. return value != null && isLength(value.length) && !isFunction(value);
  3321. }
  3322. /**
  3323. * This method is like `_.isArrayLike` except that it also checks if `value`
  3324. * is an object.
  3325. *
  3326. * @static
  3327. * @memberOf _
  3328. * @since 4.0.0
  3329. * @category Lang
  3330. * @param {*} value The value to check.
  3331. * @returns {boolean} Returns `true` if `value` is an array-like object,
  3332. * else `false`.
  3333. * @example
  3334. *
  3335. * _.isArrayLikeObject([1, 2, 3]);
  3336. * // => true
  3337. *
  3338. * _.isArrayLikeObject(document.body.children);
  3339. * // => true
  3340. *
  3341. * _.isArrayLikeObject('abc');
  3342. * // => false
  3343. *
  3344. * _.isArrayLikeObject(_.noop);
  3345. * // => false
  3346. */
  3347. function isArrayLikeObject(value) {
  3348. return isObjectLike(value) && isArrayLike(value);
  3349. }
  3350. /**
  3351. * Checks if `value` is a buffer.
  3352. *
  3353. * @static
  3354. * @memberOf _
  3355. * @since 4.3.0
  3356. * @category Lang
  3357. * @param {*} value The value to check.
  3358. * @returns {boolean} Returns `true` if `value` is a buffer, else `false`.
  3359. * @example
  3360. *
  3361. * _.isBuffer(new Buffer(2));
  3362. * // => true
  3363. *
  3364. * _.isBuffer(new Uint8Array(2));
  3365. * // => false
  3366. */
  3367. var isBuffer = nativeIsBuffer || stubFalse;
  3368. /**
  3369. * Checks if `value` is classified as a `Function` object.
  3370. *
  3371. * @static
  3372. * @memberOf _
  3373. * @since 0.1.0
  3374. * @category Lang
  3375. * @param {*} value The value to check.
  3376. * @returns {boolean} Returns `true` if `value` is a function, else `false`.
  3377. * @example
  3378. *
  3379. * _.isFunction(_);
  3380. * // => true
  3381. *
  3382. * _.isFunction(/abc/);
  3383. * // => false
  3384. */
  3385. function isFunction(value) {
  3386. if (!isObject(value)) {
  3387. return false;
  3388. }
  3389. // The use of `Object#toString` avoids issues with the `typeof` operator
  3390. // in Safari 9 which returns 'object' for typed arrays and other constructors.
  3391. var tag = baseGetTag(value);
  3392. return (tag == funcTag ||
  3393. tag == genTag ||
  3394. tag == asyncTag ||
  3395. tag == proxyTag);
  3396. }
  3397. /**
  3398. * Checks if `value` is a valid array-like length.
  3399. *
  3400. * **Note:** This method is loosely based on
  3401. * [`ToLength`](http://ecma-international.org/ecma-262/7.0/#sec-tolength).
  3402. *
  3403. * @static
  3404. * @memberOf _
  3405. * @since 4.0.0
  3406. * @category Lang
  3407. * @param {*} value The value to check.
  3408. * @returns {boolean} Returns `true` if `value` is a valid length, else `false`.
  3409. * @example
  3410. *
  3411. * _.isLength(3);
  3412. * // => true
  3413. *
  3414. * _.isLength(Number.MIN_VALUE);
  3415. * // => false
  3416. *
  3417. * _.isLength(Infinity);
  3418. * // => false
  3419. *
  3420. * _.isLength('3');
  3421. * // => false
  3422. */
  3423. function isLength(value) {
  3424. return (typeof value == "number" &&
  3425. value > -1 &&
  3426. value % 1 == 0 &&
  3427. value <= MAX_SAFE_INTEGER);
  3428. }
  3429. /**
  3430. * Checks if `value` is the
  3431. * [language type](http://www.ecma-international.org/ecma-262/7.0/#sec-ecmascript-language-types)
  3432. * of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)
  3433. *
  3434. * @static
  3435. * @memberOf _
  3436. * @since 0.1.0
  3437. * @category Lang
  3438. * @param {*} value The value to check.
  3439. * @returns {boolean} Returns `true` if `value` is an object, else `false`.
  3440. * @example
  3441. *
  3442. * _.isObject({});
  3443. * // => true
  3444. *
  3445. * _.isObject([1, 2, 3]);
  3446. * // => true
  3447. *
  3448. * _.isObject(_.noop);
  3449. * // => true
  3450. *
  3451. * _.isObject(null);
  3452. * // => false
  3453. */
  3454. function isObject(value) {
  3455. var type = typeof value;
  3456. return value != null && (type == "object" || type == "function");
  3457. }
  3458. /**
  3459. * Checks if `value` is object-like. A value is object-like if it's not `null`
  3460. * and has a `typeof` result of "object".
  3461. *
  3462. * @static
  3463. * @memberOf _
  3464. * @since 4.0.0
  3465. * @category Lang
  3466. * @param {*} value The value to check.
  3467. * @returns {boolean} Returns `true` if `value` is object-like, else `false`.
  3468. * @example
  3469. *
  3470. * _.isObjectLike({});
  3471. * // => true
  3472. *
  3473. * _.isObjectLike([1, 2, 3]);
  3474. * // => true
  3475. *
  3476. * _.isObjectLike(_.noop);
  3477. * // => false
  3478. *
  3479. * _.isObjectLike(null);
  3480. * // => false
  3481. */
  3482. function isObjectLike(value) {
  3483. return value != null && typeof value == "object";
  3484. }
  3485. /**
  3486. * Checks if `value` is a plain object, that is, an object created by the
  3487. * `Object` constructor or one with a `[[Prototype]]` of `null`.
  3488. *
  3489. * @static
  3490. * @memberOf _
  3491. * @since 0.8.0
  3492. * @category Lang
  3493. * @param {*} value The value to check.
  3494. * @returns {boolean} Returns `true` if `value` is a plain object, else `false`.
  3495. * @example
  3496. *
  3497. * function Foo() {
  3498. * this.a = 1;
  3499. * }
  3500. *
  3501. * _.isPlainObject(new Foo);
  3502. * // => false
  3503. *
  3504. * _.isPlainObject([1, 2, 3]);
  3505. * // => false
  3506. *
  3507. * _.isPlainObject({ 'x': 0, 'y': 0 });
  3508. * // => true
  3509. *
  3510. * _.isPlainObject(Object.create(null));
  3511. * // => true
  3512. */
  3513. function isPlainObject(value) {
  3514. if (!isObjectLike(value) || baseGetTag(value) != objectTag) {
  3515. return false;
  3516. }
  3517. var proto = getPrototype(value);
  3518. if (proto === null) {
  3519. return true;
  3520. }
  3521. var Ctor = hasOwnProperty.call(proto, "constructor") && proto.constructor;
  3522. return (typeof Ctor == "function" &&
  3523. Ctor instanceof Ctor &&
  3524. funcToString.call(Ctor) == objectCtorString);
  3525. }
  3526. /**
  3527. * Checks if `value` is classified as a `String` primitive or object.
  3528. *
  3529. * @static
  3530. * @since 0.1.0
  3531. * @memberOf _
  3532. * @category Lang
  3533. * @param {*} value The value to check.
  3534. * @returns {boolean} Returns `true` if `value` is a string, else `false`.
  3535. * @example
  3536. *
  3537. * _.isString('abc');
  3538. * // => true
  3539. *
  3540. * _.isString(1);
  3541. * // => false
  3542. */
  3543. function isString(value) {
  3544. return (typeof value == "string" ||
  3545. (!isArray(value) &&
  3546. isObjectLike(value) &&
  3547. baseGetTag(value) == stringTag));
  3548. }
  3549. /**
  3550. * Checks if `value` is classified as a `Symbol` primitive or object.
  3551. *
  3552. * @static
  3553. * @memberOf _
  3554. * @since 4.0.0
  3555. * @category Lang
  3556. * @param {*} value The value to check.
  3557. * @returns {boolean} Returns `true` if `value` is a symbol, else `false`.
  3558. * @example
  3559. *
  3560. * _.isSymbol(Symbol.iterator);
  3561. * // => true
  3562. *
  3563. * _.isSymbol('abc');
  3564. * // => false
  3565. */
  3566. function isSymbol(value) {
  3567. return (typeof value == "symbol" ||
  3568. (isObjectLike(value) && baseGetTag(value) == symbolTag));
  3569. }
  3570. /**
  3571. * Checks if `value` is classified as a typed array.
  3572. *
  3573. * @static
  3574. * @memberOf _
  3575. * @since 3.0.0
  3576. * @category Lang
  3577. * @param {*} value The value to check.
  3578. * @returns {boolean} Returns `true` if `value` is a typed array, else `false`.
  3579. * @example
  3580. *
  3581. * _.isTypedArray(new Uint8Array);
  3582. * // => true
  3583. *
  3584. * _.isTypedArray([]);
  3585. * // => false
  3586. */
  3587. var isTypedArray = nodeIsTypedArray
  3588. ? baseUnary(nodeIsTypedArray)
  3589. : baseIsTypedArray;
  3590. /**
  3591. * Checks if `value` is `undefined`.
  3592. *
  3593. * @static
  3594. * @since 0.1.0
  3595. * @memberOf _
  3596. * @category Lang
  3597. * @param {*} value The value to check.
  3598. * @returns {boolean} Returns `true` if `value` is `undefined`, else `false`.
  3599. * @example
  3600. *
  3601. * _.isUndefined(void 0);
  3602. * // => true
  3603. *
  3604. * _.isUndefined(null);
  3605. * // => false
  3606. */
  3607. function isUndefined(value) {
  3608. return value === undefined;
  3609. }
  3610. /**
  3611. * Converts `value` to an array.
  3612. *
  3613. * @static
  3614. * @since 0.1.0
  3615. * @memberOf _
  3616. * @category Lang
  3617. * @param {*} value The value to convert.
  3618. * @returns {Array} Returns the converted array.
  3619. * @example
  3620. *
  3621. * _.toArray({ 'a': 1, 'b': 2 });
  3622. * // => [1, 2]
  3623. *
  3624. * _.toArray('abc');
  3625. * // => ['a', 'b', 'c']
  3626. *
  3627. * _.toArray(1);
  3628. * // => []
  3629. *
  3630. * _.toArray(null);
  3631. * // => []
  3632. */
  3633. function toArray(value) {
  3634. if (!value) {
  3635. return [];
  3636. }
  3637. if (isArrayLike(value)) {
  3638. return isString(value) ? stringToArray(value) : copyArray(value);
  3639. }
  3640. if (symIterator && value[symIterator]) {
  3641. return iteratorToArray(value[symIterator]());
  3642. }
  3643. var tag = getTag(value), func = tag == mapTag
  3644. ? mapToArray
  3645. : tag == setTag ? setToArray : values;
  3646. return func(value);
  3647. }
  3648. /**
  3649. * Converts `value` to a finite number.
  3650. *
  3651. * @static
  3652. * @memberOf _
  3653. * @since 4.12.0
  3654. * @category Lang
  3655. * @param {*} value The value to convert.
  3656. * @returns {number} Returns the converted number.
  3657. * @example
  3658. *
  3659. * _.toFinite(3.2);
  3660. * // => 3.2
  3661. *
  3662. * _.toFinite(Number.MIN_VALUE);
  3663. * // => 5e-324
  3664. *
  3665. * _.toFinite(Infinity);
  3666. * // => 1.7976931348623157e+308
  3667. *
  3668. * _.toFinite('3.2');
  3669. * // => 3.2
  3670. */
  3671. function toFinite(value) {
  3672. if (!value) {
  3673. return value === 0 ? value : 0;
  3674. }
  3675. value = toNumber(value);
  3676. if (value === INFINITY || value === -INFINITY) {
  3677. var sign = value < 0 ? -1 : 1;
  3678. return sign * MAX_INTEGER;
  3679. }
  3680. return value === value ? value : 0;
  3681. }
  3682. /**
  3683. * Converts `value` to an integer.
  3684. *
  3685. * **Note:** This method is loosely based on
  3686. * [`ToInteger`](http://www.ecma-international.org/ecma-262/7.0/#sec-tointeger).
  3687. *
  3688. * @static
  3689. * @memberOf _
  3690. * @since 4.0.0
  3691. * @category Lang
  3692. * @param {*} value The value to convert.
  3693. * @returns {number} Returns the converted integer.
  3694. * @example
  3695. *
  3696. * _.toInteger(3.2);
  3697. * // => 3
  3698. *
  3699. * _.toInteger(Number.MIN_VALUE);
  3700. * // => 0
  3701. *
  3702. * _.toInteger(Infinity);
  3703. * // => 1.7976931348623157e+308
  3704. *
  3705. * _.toInteger('3.2');
  3706. * // => 3
  3707. */
  3708. function toInteger(value) {
  3709. var result = toFinite(value), remainder = result % 1;
  3710. return result === result
  3711. ? remainder ? result - remainder : result
  3712. : 0;
  3713. }
  3714. /**
  3715. * Converts `value` to a number.
  3716. *
  3717. * @static
  3718. * @memberOf _
  3719. * @since 4.0.0
  3720. * @category Lang
  3721. * @param {*} value The value to process.
  3722. * @returns {number} Returns the number.
  3723. * @example
  3724. *
  3725. * _.toNumber(3.2);
  3726. * // => 3.2
  3727. *
  3728. * _.toNumber(Number.MIN_VALUE);
  3729. * // => 5e-324
  3730. *
  3731. * _.toNumber(Infinity);
  3732. * // => Infinity
  3733. *
  3734. * _.toNumber('3.2');
  3735. * // => 3.2
  3736. */
  3737. function toNumber(value) {
  3738. if (typeof value == "number") {
  3739. return value;
  3740. }
  3741. if (isSymbol(value)) {
  3742. return NAN;
  3743. }
  3744. if (isObject(value)) {
  3745. var other = typeof value.valueOf == "function" ? value.valueOf() : value;
  3746. value = isObject(other) ? other + "" : other;
  3747. }
  3748. if (typeof value != "string") {
  3749. return value === 0 ? value : +value;
  3750. }
  3751. value = value.replace(reTrim, "");
  3752. var isBinary = reIsBinary.test(value);
  3753. return isBinary || reIsOctal.test(value)
  3754. ? freeParseInt(value.slice(2), isBinary ? 2 : 8)
  3755. : reIsBadHex.test(value) ? NAN : +value;
  3756. }
  3757. /**
  3758. * Converts `value` to a plain object flattening inherited enumerable string
  3759. * keyed properties of `value` to own properties of the plain object.
  3760. *
  3761. * @static
  3762. * @memberOf _
  3763. * @since 3.0.0
  3764. * @category Lang
  3765. * @param {*} value The value to convert.
  3766. * @returns {Object} Returns the converted plain object.
  3767. * @example
  3768. *
  3769. * function Foo() {
  3770. * this.b = 2;
  3771. * }
  3772. *
  3773. * Foo.prototype.c = 3;
  3774. *
  3775. * _.assign({ 'a': 1 }, new Foo);
  3776. * // => { 'a': 1, 'b': 2 }
  3777. *
  3778. * _.assign({ 'a': 1 }, _.toPlainObject(new Foo));
  3779. * // => { 'a': 1, 'b': 2, 'c': 3 }
  3780. */
  3781. function toPlainObject(value) {
  3782. return copyObject(value, keysIn(value));
  3783. }
  3784. /**
  3785. * Converts `value` to a string. An empty string is returned for `null`
  3786. * and `undefined` values. The sign of `-0` is preserved.
  3787. *
  3788. * @static
  3789. * @memberOf _
  3790. * @since 4.0.0
  3791. * @category Lang
  3792. * @param {*} value The value to convert.
  3793. * @returns {string} Returns the converted string.
  3794. * @example
  3795. *
  3796. * _.toString(null);
  3797. * // => ''
  3798. *
  3799. * _.toString(-0);
  3800. * // => '-0'
  3801. *
  3802. * _.toString([1, 2, 3]);
  3803. * // => '1,2,3'
  3804. */
  3805. function toString(value) {
  3806. return value == null ? "" : baseToString(value);
  3807. }
  3808. /*------------------------------------------------------------------------*/
  3809. /**
  3810. * Gets the value at `path` of `object`. If the resolved value is
  3811. * `undefined`, the `defaultValue` is returned in its place.
  3812. *
  3813. * @static
  3814. * @memberOf _
  3815. * @since 3.7.0
  3816. * @category Object
  3817. * @param {Object} object The object to query.
  3818. * @param {Array|string} path The path of the property to get.
  3819. * @param {*} [defaultValue] The value returned for `undefined` resolved values.
  3820. * @returns {*} Returns the resolved value.
  3821. * @example
  3822. *
  3823. * var object = { 'a': [{ 'b': { 'c': 3 } }] };
  3824. *
  3825. * _.get(object, 'a[0].b.c');
  3826. * // => 3
  3827. *
  3828. * _.get(object, ['a', '0', 'b', 'c']);
  3829. * // => 3
  3830. *
  3831. * _.get(object, 'a.b.c', 'default');
  3832. * // => 'default'
  3833. */
  3834. function get(object, path, defaultValue) {
  3835. var result = object == null ? undefined : baseGet(object, path);
  3836. return result === undefined ? defaultValue : result;
  3837. }
  3838. /**
  3839. * Checks if `path` is a direct or inherited property of `object`.
  3840. *
  3841. * @static
  3842. * @memberOf _
  3843. * @since 4.0.0
  3844. * @category Object
  3845. * @param {Object} object The object to query.
  3846. * @param {Array|string} path The path to check.
  3847. * @returns {boolean} Returns `true` if `path` exists, else `false`.
  3848. * @example
  3849. *
  3850. * var object = _.create({ 'a': _.create({ 'b': 2 }) });
  3851. *
  3852. * _.hasIn(object, 'a');
  3853. * // => true
  3854. *
  3855. * _.hasIn(object, 'a.b');
  3856. * // => true
  3857. *
  3858. * _.hasIn(object, ['a', 'b']);
  3859. * // => true
  3860. *
  3861. * _.hasIn(object, 'b');
  3862. * // => false
  3863. */
  3864. function hasIn(object, path) {
  3865. return object != null && hasPath(object, path, baseHasIn);
  3866. }
  3867. /**
  3868. * Creates an array of the own enumerable property names of `object`.
  3869. *
  3870. * **Note:** Non-object values are coerced to objects. See the
  3871. * [ES spec](http://ecma-international.org/ecma-262/7.0/#sec-object.keys)
  3872. * for more details.
  3873. *
  3874. * @static
  3875. * @since 0.1.0
  3876. * @memberOf _
  3877. * @category Object
  3878. * @param {Object} object The object to query.
  3879. * @returns {Array} Returns the array of property names.
  3880. * @example
  3881. *
  3882. * function Foo() {
  3883. * this.a = 1;
  3884. * this.b = 2;
  3885. * }
  3886. *
  3887. * Foo.prototype.c = 3;
  3888. *
  3889. * _.keys(new Foo);
  3890. * // => ['a', 'b'] (iteration order is not guaranteed)
  3891. *
  3892. * _.keys('hi');
  3893. * // => ['0', '1']
  3894. */
  3895. function keys(object) {
  3896. return isArrayLike(object) ? arrayLikeKeys(object) : baseKeys(object);
  3897. }
  3898. /**
  3899. * Creates an array of the own and inherited enumerable property names of `object`.
  3900. *
  3901. * **Note:** Non-object values are coerced to objects.
  3902. *
  3903. * @static
  3904. * @memberOf _
  3905. * @since 3.0.0
  3906. * @category Object
  3907. * @param {Object} object The object to query.
  3908. * @returns {Array} Returns the array of property names.
  3909. * @example
  3910. *
  3911. * function Foo() {
  3912. * this.a = 1;
  3913. * this.b = 2;
  3914. * }
  3915. *
  3916. * Foo.prototype.c = 3;
  3917. *
  3918. * _.keysIn(new Foo);
  3919. * // => ['a', 'b', 'c'] (iteration order is not guaranteed)
  3920. */
  3921. function keysIn(object) {
  3922. return isArrayLike(object)
  3923. ? arrayLikeKeys(object, true)
  3924. : baseKeysIn(object);
  3925. }
  3926. /**
  3927. * This method is like `_.assign` except that it recursively merges own and
  3928. * inherited enumerable string keyed properties of source objects into the
  3929. * destination object. Source properties that resolve to `undefined` are
  3930. * skipped if a destination value exists. Array and plain object properties
  3931. * are merged recursively. Other objects and value types are overridden by
  3932. * assignment. Source objects are applied from left to right. Subsequent
  3933. * sources overwrite property assignments of previous sources.
  3934. *
  3935. * **Note:** This method mutates `object`.
  3936. *
  3937. * @static
  3938. * @memberOf _
  3939. * @since 0.5.0
  3940. * @category Object
  3941. * @param {Object} object The destination object.
  3942. * @param {...Object} [sources] The source objects.
  3943. * @returns {Object} Returns `object`.
  3944. * @example
  3945. *
  3946. * var object = {
  3947. * 'a': [{ 'b': 2 }, { 'd': 4 }]
  3948. * };
  3949. *
  3950. * var other = {
  3951. * 'a': [{ 'c': 3 }, { 'e': 5 }]
  3952. * };
  3953. *
  3954. * _.merge(object, other);
  3955. * // => { 'a': [{ 'b': 2, 'c': 3 }, { 'd': 4, 'e': 5 }] }
  3956. */
  3957. var merge = createAssigner(function (object, source, srcIndex) {
  3958. baseMerge(object, source, srcIndex);
  3959. });
  3960. /**
  3961. * Sets the value at `path` of `object`. If a portion of `path` doesn't exist,
  3962. * it's created. Arrays are created for missing index properties while objects
  3963. * are created for all other missing properties. Use `_.setWith` to customize
  3964. * `path` creation.
  3965. *
  3966. * **Note:** This method mutates `object`.
  3967. *
  3968. * @static
  3969. * @memberOf _
  3970. * @since 3.7.0
  3971. * @category Object
  3972. * @param {Object} object The object to modify.
  3973. * @param {Array|string} path The path of the property to set.
  3974. * @param {*} value The value to set.
  3975. * @returns {Object} Returns `object`.
  3976. * @example
  3977. *
  3978. * var object = { 'a': [{ 'b': { 'c': 3 } }] };
  3979. *
  3980. * _.set(object, 'a[0].b.c', 4);
  3981. * console.log(object.a[0].b.c);
  3982. * // => 4
  3983. *
  3984. * _.set(object, ['x', '0', 'y', 'z'], 5);
  3985. * console.log(object.x[0].y.z);
  3986. * // => 5
  3987. */
  3988. function set(object, path, value) {
  3989. return object == null ? object : baseSet(object, path, value);
  3990. }
  3991. /**
  3992. * Creates an array of the own enumerable string keyed property values of `object`.
  3993. *
  3994. * **Note:** Non-object values are coerced to objects.
  3995. *
  3996. * @static
  3997. * @since 0.1.0
  3998. * @memberOf _
  3999. * @category Object
  4000. * @param {Object} object The object to query.
  4001. * @returns {Array} Returns the array of property values.
  4002. * @example
  4003. *
  4004. * function Foo() {
  4005. * this.a = 1;
  4006. * this.b = 2;
  4007. * }
  4008. *
  4009. * Foo.prototype.c = 3;
  4010. *
  4011. * _.values(new Foo);
  4012. * // => [1, 2] (iteration order is not guaranteed)
  4013. *
  4014. * _.values('hi');
  4015. * // => ['h', 'i']
  4016. */
  4017. function values(object) {
  4018. return object == null ? [] : baseValues(object, keys(object));
  4019. }
  4020. /*------------------------------------------------------------------------*/
  4021. /**
  4022. * Creates a function that returns `value`.
  4023. *
  4024. * @static
  4025. * @memberOf _
  4026. * @since 2.4.0
  4027. * @category Util
  4028. * @param {*} value The value to return from the new function.
  4029. * @returns {Function} Returns the new constant function.
  4030. * @example
  4031. *
  4032. * var objects = _.times(2, _.constant({ 'a': 1 }));
  4033. *
  4034. * console.log(objects);
  4035. * // => [{ 'a': 1 }, { 'a': 1 }]
  4036. *
  4037. * console.log(objects[0] === objects[1]);
  4038. * // => true
  4039. */
  4040. function constant(value) {
  4041. return function () {
  4042. return value;
  4043. };
  4044. }
  4045. /**
  4046. * This method returns the first argument it receives.
  4047. *
  4048. * @static
  4049. * @since 0.1.0
  4050. * @memberOf _
  4051. * @category Util
  4052. * @param {*} value Any value.
  4053. * @returns {*} Returns `value`.
  4054. * @example
  4055. *
  4056. * var object = { 'a': 1 };
  4057. *
  4058. * console.log(_.identity(object) === object);
  4059. * // => true
  4060. */
  4061. function identity(value) {
  4062. return value;
  4063. }
  4064. /**
  4065. * Creates a function that invokes `func` with the arguments of the created
  4066. * function. If `func` is a property name, the created function returns the
  4067. * property value for a given element. If `func` is an array or object, the
  4068. * created function returns `true` for elements that contain the equivalent
  4069. * source properties, otherwise it returns `false`.
  4070. *
  4071. * @static
  4072. * @since 4.0.0
  4073. * @memberOf _
  4074. * @category Util
  4075. * @param {*} [func=_.identity] The value to convert to a callback.
  4076. * @returns {Function} Returns the callback.
  4077. * @example
  4078. *
  4079. * var users = [
  4080. * { 'user': 'barney', 'age': 36, 'active': true },
  4081. * { 'user': 'fred', 'age': 40, 'active': false }
  4082. * ];
  4083. *
  4084. * // The `_.matches` iteratee shorthand.
  4085. * _.filter(users, _.iteratee({ 'user': 'barney', 'active': true }));
  4086. * // => [{ 'user': 'barney', 'age': 36, 'active': true }]
  4087. *
  4088. * // The `_.matchesProperty` iteratee shorthand.
  4089. * _.filter(users, _.iteratee(['user', 'fred']));
  4090. * // => [{ 'user': 'fred', 'age': 40 }]
  4091. *
  4092. * // The `_.property` iteratee shorthand.
  4093. * _.map(users, _.iteratee('user'));
  4094. * // => ['barney', 'fred']
  4095. *
  4096. * // Create custom iteratee shorthands.
  4097. * _.iteratee = _.wrap(_.iteratee, function(iteratee, func) {
  4098. * return !_.isRegExp(func) ? iteratee(func) : function(string) {
  4099. * return func.test(string);
  4100. * };
  4101. * });
  4102. *
  4103. * _.filter(['abc', 'def'], /ef/);
  4104. * // => ['def']
  4105. */
  4106. function iteratee(func) {
  4107. return baseIteratee(typeof func == "function" ? func : baseClone(func, CLONE_DEEP_FLAG));
  4108. }
  4109. /**
  4110. * This method returns `undefined`.
  4111. *
  4112. * @static
  4113. * @memberOf _
  4114. * @since 2.3.0
  4115. * @category Util
  4116. * @example
  4117. *
  4118. * _.times(2, _.noop);
  4119. * // => [undefined, undefined]
  4120. */
  4121. function noop() {
  4122. // No operation performed.
  4123. }
  4124. /**
  4125. * Creates a function that returns the value at `path` of a given object.
  4126. *
  4127. * @static
  4128. * @memberOf _
  4129. * @since 2.4.0
  4130. * @category Util
  4131. * @param {Array|string} path The path of the property to get.
  4132. * @returns {Function} Returns the new accessor function.
  4133. * @example
  4134. *
  4135. * var objects = [
  4136. * { 'a': { 'b': 2 } },
  4137. * { 'a': { 'b': 1 } }
  4138. * ];
  4139. *
  4140. * _.map(objects, _.property('a.b'));
  4141. * // => [2, 1]
  4142. *
  4143. * _.map(_.sortBy(objects, _.property(['a', 'b'])), 'a.b');
  4144. * // => [1, 2]
  4145. */
  4146. function property(path) {
  4147. return isKey(path) ? baseProperty(toKey(path)) : basePropertyDeep(path);
  4148. }
  4149. /**
  4150. * This method returns a new empty array.
  4151. *
  4152. * @static
  4153. * @memberOf _
  4154. * @since 4.13.0
  4155. * @category Util
  4156. * @returns {Array} Returns the new empty array.
  4157. * @example
  4158. *
  4159. * var arrays = _.times(2, _.stubArray);
  4160. *
  4161. * console.log(arrays);
  4162. * // => [[], []]
  4163. *
  4164. * console.log(arrays[0] === arrays[1]);
  4165. * // => false
  4166. */
  4167. function stubArray() {
  4168. return [];
  4169. }
  4170. /**
  4171. * This method returns `false`.
  4172. *
  4173. * @static
  4174. * @memberOf _
  4175. * @since 4.13.0
  4176. * @category Util
  4177. * @returns {boolean} Returns `false`.
  4178. * @example
  4179. *
  4180. * _.times(2, _.stubFalse);
  4181. * // => [false, false]
  4182. */
  4183. function stubFalse() {
  4184. return false;
  4185. }
  4186. /*------------------------------------------------------------------------*/
  4187. // Add methods that return wrapped values in chain sequences.
  4188. lodash.constant = constant;
  4189. lodash.iteratee = iteratee;
  4190. lodash.keys = keys;
  4191. lodash.keysIn = keysIn;
  4192. lodash.memoize = memoize;
  4193. lodash.merge = merge;
  4194. lodash.property = property;
  4195. lodash.set = set;
  4196. lodash.toArray = toArray;
  4197. lodash.toPlainObject = toPlainObject;
  4198. lodash.union = union;
  4199. lodash.values = values;
  4200. /*------------------------------------------------------------------------*/
  4201. // Add methods that return unwrapped values in chain sequences.
  4202. lodash.eq = eq;
  4203. lodash.forEach = forEach;
  4204. lodash.get = get;
  4205. lodash.hasIn = hasIn;
  4206. lodash.identity = identity;
  4207. lodash.includes = includes;
  4208. lodash.isArguments = isArguments;
  4209. lodash.isArray = isArray;
  4210. lodash.isArrayLike = isArrayLike;
  4211. lodash.isArrayLikeObject = isArrayLikeObject;
  4212. lodash.isBuffer = isBuffer;
  4213. lodash.isFunction = isFunction;
  4214. lodash.isLength = isLength;
  4215. lodash.isObject = isObject;
  4216. lodash.isObjectLike = isObjectLike;
  4217. lodash.isPlainObject = isPlainObject;
  4218. lodash.isString = isString;
  4219. lodash.isSymbol = isSymbol;
  4220. lodash.isTypedArray = isTypedArray;
  4221. lodash.isUndefined = isUndefined;
  4222. lodash.stubArray = stubArray;
  4223. lodash.stubFalse = stubFalse;
  4224. lodash.noop = noop;
  4225. lodash.toFinite = toFinite;
  4226. lodash.toInteger = toInteger;
  4227. lodash.toNumber = toNumber;
  4228. lodash.toString = toString;
  4229. // Add aliases.
  4230. lodash.each = forEach;
  4231. /*------------------------------------------------------------------------*/
  4232. /**
  4233. * The semantic version number.
  4234. *
  4235. * @static
  4236. * @memberOf _
  4237. * @type {string}
  4238. */
  4239. lodash.VERSION = VERSION;
  4240. /*--------------------------------------------------------------------------*/
  4241. if (freeModule) {
  4242. // Export for Node.js.
  4243. (freeModule.exports = lodash)._ = lodash;
  4244. // Export for CommonJS support.
  4245. freeExports._ = lodash;
  4246. }
  4247. }.call(this));
  4248. //# sourceMappingURL=lodash.custom.js.map