lodash.custom.js 76 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672
  1. /**
  2. * @license
  3. * lodash (Custom Build) <https://lodash.com/>
  4. * Build: `lodash include="cloneDeep,merge" exports="node"`
  5. * Copyright jQuery Foundation and other contributors <https://jquery.org/>
  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.12.0';
  15. /** Used as the size to enable large array optimizations. */
  16. var LARGE_ARRAY_SIZE = 200;
  17. /** Used as the `TypeError` message for "Functions" methods. */
  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 references for various `Number` constants. */
  22. var INFINITY = 1 / 0,
  23. MAX_SAFE_INTEGER = 9007199254740991,
  24. MAX_INTEGER = 1.7976931348623157e+308,
  25. NAN = 0 / 0;
  26. /** `Object#toString` result references. */
  27. var argsTag = '[object Arguments]',
  28. arrayTag = '[object Array]',
  29. boolTag = '[object Boolean]',
  30. dateTag = '[object Date]',
  31. errorTag = '[object Error]',
  32. funcTag = '[object Function]',
  33. genTag = '[object GeneratorFunction]',
  34. mapTag = '[object Map]',
  35. numberTag = '[object Number]',
  36. objectTag = '[object Object]',
  37. promiseTag = '[object Promise]',
  38. regexpTag = '[object RegExp]',
  39. setTag = '[object Set]',
  40. stringTag = '[object String]',
  41. symbolTag = '[object Symbol]',
  42. weakMapTag = '[object WeakMap]';
  43. var arrayBufferTag = '[object ArrayBuffer]',
  44. dataViewTag = '[object DataView]',
  45. float32Tag = '[object Float32Array]',
  46. float64Tag = '[object Float64Array]',
  47. int8Tag = '[object Int8Array]',
  48. int16Tag = '[object Int16Array]',
  49. int32Tag = '[object Int32Array]',
  50. uint8Tag = '[object Uint8Array]',
  51. uint8ClampedTag = '[object Uint8ClampedArray]',
  52. uint16Tag = '[object Uint16Array]',
  53. uint32Tag = '[object Uint32Array]';
  54. /**
  55. * Used to match `RegExp`
  56. * [syntax characters](http://ecma-international.org/ecma-262/6.0/#sec-patterns).
  57. */
  58. var reRegExpChar = /[\\^$.*+?()[\]{}|]/g;
  59. /** Used to match leading and trailing whitespace. */
  60. var reTrim = /^\s+|\s+$/g;
  61. /** Used to match `RegExp` flags from their coerced string values. */
  62. var reFlags = /\w*$/;
  63. /** Used to detect bad signed hexadecimal string values. */
  64. var reIsBadHex = /^[-+]0x[0-9a-f]+$/i;
  65. /** Used to detect binary string values. */
  66. var reIsBinary = /^0b[01]+$/i;
  67. /** Used to detect host constructors (Safari). */
  68. var reIsHostCtor = /^\[object .+?Constructor\]$/;
  69. /** Used to detect octal string values. */
  70. var reIsOctal = /^0o[0-7]+$/i;
  71. /** Used to detect unsigned integer values. */
  72. var reIsUint = /^(?:0|[1-9]\d*)$/;
  73. /** Used to identify `toStringTag` values of typed arrays. */
  74. var typedArrayTags = {};
  75. typedArrayTags[float32Tag] = typedArrayTags[float64Tag] =
  76. typedArrayTags[int8Tag] = typedArrayTags[int16Tag] =
  77. typedArrayTags[int32Tag] = typedArrayTags[uint8Tag] =
  78. typedArrayTags[uint8ClampedTag] = typedArrayTags[uint16Tag] =
  79. typedArrayTags[uint32Tag] = true;
  80. typedArrayTags[argsTag] = typedArrayTags[arrayTag] =
  81. typedArrayTags[arrayBufferTag] = typedArrayTags[boolTag] =
  82. typedArrayTags[dataViewTag] = typedArrayTags[dateTag] =
  83. typedArrayTags[errorTag] = typedArrayTags[funcTag] =
  84. typedArrayTags[mapTag] = typedArrayTags[numberTag] =
  85. typedArrayTags[objectTag] = typedArrayTags[regexpTag] =
  86. typedArrayTags[setTag] = typedArrayTags[stringTag] =
  87. typedArrayTags[weakMapTag] = false;
  88. /** Used to identify `toStringTag` values supported by `_.clone`. */
  89. var cloneableTags = {};
  90. cloneableTags[argsTag] = cloneableTags[arrayTag] =
  91. cloneableTags[arrayBufferTag] = cloneableTags[dataViewTag] =
  92. cloneableTags[boolTag] = cloneableTags[dateTag] =
  93. cloneableTags[float32Tag] = cloneableTags[float64Tag] =
  94. cloneableTags[int8Tag] = cloneableTags[int16Tag] =
  95. cloneableTags[int32Tag] = cloneableTags[mapTag] =
  96. cloneableTags[numberTag] = cloneableTags[objectTag] =
  97. cloneableTags[regexpTag] = cloneableTags[setTag] =
  98. cloneableTags[stringTag] = cloneableTags[symbolTag] =
  99. cloneableTags[uint8Tag] = cloneableTags[uint8ClampedTag] =
  100. cloneableTags[uint16Tag] = cloneableTags[uint32Tag] = true;
  101. cloneableTags[errorTag] = cloneableTags[funcTag] =
  102. cloneableTags[weakMapTag] = false;
  103. /** Used to determine if values are of the language type `Object`. */
  104. var objectTypes = {
  105. 'function': true,
  106. 'object': true
  107. };
  108. /** Built-in method references without a dependency on `root`. */
  109. var freeParseInt = parseInt;
  110. /** Detect free variable `exports`. */
  111. var freeExports = (objectTypes[typeof exports] && exports && !exports.nodeType)
  112. ? exports
  113. : undefined;
  114. /** Detect free variable `module`. */
  115. var freeModule = (objectTypes[typeof module] && module && !module.nodeType)
  116. ? module
  117. : undefined;
  118. /** Detect the popular CommonJS extension `module.exports`. */
  119. var moduleExports = (freeModule && freeModule.exports === freeExports)
  120. ? freeExports
  121. : undefined;
  122. /** Detect free variable `global` from Node.js. */
  123. var freeGlobal = checkGlobal(freeExports && freeModule && typeof global == 'object' && global);
  124. /** Detect free variable `self`. */
  125. var freeSelf = checkGlobal(objectTypes[typeof self] && self);
  126. /** Detect free variable `window`. */
  127. var freeWindow = checkGlobal(objectTypes[typeof window] && window);
  128. /** Detect `this` as the global object. */
  129. var thisGlobal = checkGlobal(objectTypes[typeof this] && this);
  130. /**
  131. * Used as a reference to the global object.
  132. *
  133. * The `this` value is used if it's the global object to avoid Greasemonkey's
  134. * restricted `window` object, otherwise the `window` object is used.
  135. */
  136. var root = freeGlobal ||
  137. ((freeWindow !== (thisGlobal && thisGlobal.window)) && freeWindow) ||
  138. freeSelf || thisGlobal || Function('return this')();
  139. /*--------------------------------------------------------------------------*/
  140. /**
  141. * Adds the key-value `pair` to `map`.
  142. *
  143. * @private
  144. * @param {Object} map The map to modify.
  145. * @param {Array} pair The key-value pair to add.
  146. * @returns {Object} Returns `map`.
  147. */
  148. function addMapEntry(map, pair) {
  149. // Don't return `Map#set` because it doesn't return the map instance in IE 11.
  150. map.set(pair[0], pair[1]);
  151. return map;
  152. }
  153. /**
  154. * Adds `value` to `set`.
  155. *
  156. * @private
  157. * @param {Object} set The set to modify.
  158. * @param {*} value The value to add.
  159. * @returns {Object} Returns `set`.
  160. */
  161. function addSetEntry(set, value) {
  162. set.add(value);
  163. return set;
  164. }
  165. /**
  166. * A faster alternative to `Function#apply`, this function invokes `func`
  167. * with the `this` binding of `thisArg` and the arguments of `args`.
  168. *
  169. * @private
  170. * @param {Function} func The function to invoke.
  171. * @param {*} thisArg The `this` binding of `func`.
  172. * @param {Array} args The arguments to invoke `func` with.
  173. * @returns {*} Returns the result of `func`.
  174. */
  175. function apply(func, thisArg, args) {
  176. var length = args.length;
  177. switch (length) {
  178. case 0: return func.call(thisArg);
  179. case 1: return func.call(thisArg, args[0]);
  180. case 2: return func.call(thisArg, args[0], args[1]);
  181. case 3: return func.call(thisArg, args[0], args[1], args[2]);
  182. }
  183. return func.apply(thisArg, args);
  184. }
  185. /**
  186. * A specialized version of `_.forEach` for arrays without support for
  187. * iteratee shorthands.
  188. *
  189. * @private
  190. * @param {Array} array The array to iterate over.
  191. * @param {Function} iteratee The function invoked per iteration.
  192. * @returns {Array} Returns `array`.
  193. */
  194. function arrayEach(array, iteratee) {
  195. var index = -1,
  196. length = array.length;
  197. while (++index < length) {
  198. if (iteratee(array[index], index, array) === false) {
  199. break;
  200. }
  201. }
  202. return array;
  203. }
  204. /**
  205. * Appends the elements of `values` to `array`.
  206. *
  207. * @private
  208. * @param {Array} array The array to modify.
  209. * @param {Array} values The values to append.
  210. * @returns {Array} Returns `array`.
  211. */
  212. function arrayPush(array, values) {
  213. var index = -1,
  214. length = values.length,
  215. offset = array.length;
  216. while (++index < length) {
  217. array[offset + index] = values[index];
  218. }
  219. return array;
  220. }
  221. /**
  222. * A specialized version of `_.reduce` for arrays without support for
  223. * iteratee shorthands.
  224. *
  225. * @private
  226. * @param {Array} array The array to iterate over.
  227. * @param {Function} iteratee The function invoked per iteration.
  228. * @param {*} [accumulator] The initial value.
  229. * @param {boolean} [initAccum] Specify using the first element of `array` as
  230. * the initial value.
  231. * @returns {*} Returns the accumulated value.
  232. */
  233. function arrayReduce(array, iteratee, accumulator, initAccum) {
  234. var index = -1,
  235. length = array.length;
  236. if (initAccum && length) {
  237. accumulator = array[++index];
  238. }
  239. while (++index < length) {
  240. accumulator = iteratee(accumulator, array[index], index, array);
  241. }
  242. return accumulator;
  243. }
  244. /**
  245. * The base implementation of `_.times` without support for iteratee shorthands
  246. * or max array length checks.
  247. *
  248. * @private
  249. * @param {number} n The number of times to invoke `iteratee`.
  250. * @param {Function} iteratee The function invoked per iteration.
  251. * @returns {Array} Returns the array of results.
  252. */
  253. function baseTimes(n, iteratee) {
  254. var index = -1,
  255. result = Array(n);
  256. while (++index < n) {
  257. result[index] = iteratee(index);
  258. }
  259. return result;
  260. }
  261. /**
  262. * Checks if `value` is a global object.
  263. *
  264. * @private
  265. * @param {*} value The value to check.
  266. * @returns {null|Object} Returns `value` if it's a global object, else `null`.
  267. */
  268. function checkGlobal(value) {
  269. return (value && value.Object === Object) ? value : null;
  270. }
  271. /**
  272. * Checks if `value` is a host object in IE < 9.
  273. *
  274. * @private
  275. * @param {*} value The value to check.
  276. * @returns {boolean} Returns `true` if `value` is a host object, else `false`.
  277. */
  278. function isHostObject(value) {
  279. // Many host objects are `Object` objects that can coerce to strings
  280. // despite having improperly defined `toString` methods.
  281. var result = false;
  282. if (value != null && typeof value.toString != 'function') {
  283. try {
  284. result = !!(value + '');
  285. } catch (e) {}
  286. }
  287. return result;
  288. }
  289. /**
  290. * Converts `iterator` to an array.
  291. *
  292. * @private
  293. * @param {Object} iterator The iterator to convert.
  294. * @returns {Array} Returns the converted array.
  295. */
  296. function iteratorToArray(iterator) {
  297. var data,
  298. result = [];
  299. while (!(data = iterator.next()).done) {
  300. result.push(data.value);
  301. }
  302. return result;
  303. }
  304. /**
  305. * Converts `map` to its key-value pairs.
  306. *
  307. * @private
  308. * @param {Object} map The map to convert.
  309. * @returns {Array} Returns the key-value pairs.
  310. */
  311. function mapToArray(map) {
  312. var index = -1,
  313. result = Array(map.size);
  314. map.forEach(function(value, key) {
  315. result[++index] = [key, value];
  316. });
  317. return result;
  318. }
  319. /**
  320. * Converts `set` to an array of its values.
  321. *
  322. * @private
  323. * @param {Object} set The set to convert.
  324. * @returns {Array} Returns the values.
  325. */
  326. function setToArray(set) {
  327. var index = -1,
  328. result = Array(set.size);
  329. set.forEach(function(value) {
  330. result[++index] = value;
  331. });
  332. return result;
  333. }
  334. /*--------------------------------------------------------------------------*/
  335. /** Used for built-in method references. */
  336. var arrayProto = Array.prototype,
  337. objectProto = Object.prototype;
  338. /** Used to resolve the decompiled source of functions. */
  339. var funcToString = Function.prototype.toString;
  340. /** Used to check objects for own properties. */
  341. var hasOwnProperty = objectProto.hasOwnProperty;
  342. /** Used to infer the `Object` constructor. */
  343. var objectCtorString = funcToString.call(Object);
  344. /**
  345. * Used to resolve the
  346. * [`toStringTag`](http://ecma-international.org/ecma-262/6.0/#sec-object.prototype.tostring)
  347. * of values.
  348. */
  349. var objectToString = objectProto.toString;
  350. /** Used to detect if a method is native. */
  351. var reIsNative = RegExp('^' +
  352. funcToString.call(hasOwnProperty).replace(reRegExpChar, '\\$&')
  353. .replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, '$1.*?') + '$'
  354. );
  355. /** Built-in value references. */
  356. var Buffer = moduleExports ? root.Buffer : undefined,
  357. Reflect = root.Reflect,
  358. Symbol = root.Symbol,
  359. Uint8Array = root.Uint8Array,
  360. enumerate = Reflect ? Reflect.enumerate : undefined,
  361. getOwnPropertySymbols = Object.getOwnPropertySymbols,
  362. objectCreate = Object.create,
  363. propertyIsEnumerable = objectProto.propertyIsEnumerable,
  364. splice = arrayProto.splice;
  365. /* Built-in method references for those with the same name as other `lodash` methods. */
  366. var nativeGetPrototype = Object.getPrototypeOf,
  367. nativeKeys = Object.keys,
  368. nativeMax = Math.max;
  369. /* Built-in method references that are verified to be native. */
  370. var DataView = getNative(root, 'DataView'),
  371. Map = getNative(root, 'Map'),
  372. Promise = getNative(root, 'Promise'),
  373. Set = getNative(root, 'Set'),
  374. WeakMap = getNative(root, 'WeakMap'),
  375. nativeCreate = getNative(Object, 'create');
  376. /** Used to lookup unminified function names. */
  377. var realNames = {};
  378. /** Used to detect maps, sets, and weakmaps. */
  379. var dataViewCtorString = toSource(DataView),
  380. mapCtorString = toSource(Map),
  381. promiseCtorString = toSource(Promise),
  382. setCtorString = toSource(Set),
  383. weakMapCtorString = toSource(WeakMap);
  384. /** Used to convert symbols to primitives and strings. */
  385. var symbolProto = Symbol ? Symbol.prototype : undefined,
  386. symbolValueOf = symbolProto ? symbolProto.valueOf : undefined;
  387. /*------------------------------------------------------------------------*/
  388. /**
  389. * Creates a `lodash` object which wraps `value` to enable implicit method
  390. * chain sequences. Methods that operate on and return arrays, collections,
  391. * and functions can be chained together. Methods that retrieve a single value
  392. * or may return a primitive value will automatically end the chain sequence
  393. * and return the unwrapped value. Otherwise, the value must be unwrapped
  394. * with `_#value`.
  395. *
  396. * Explicit chain sequences, which must be unwrapped with `_#value`, may be
  397. * enabled using `_.chain`.
  398. *
  399. * The execution of chained methods is lazy, that is, it's deferred until
  400. * `_#value` is implicitly or explicitly called.
  401. *
  402. * Lazy evaluation allows several methods to support shortcut fusion.
  403. * Shortcut fusion is an optimization to merge iteratee calls; this avoids
  404. * the creation of intermediate arrays and can greatly reduce the number of
  405. * iteratee executions. Sections of a chain sequence qualify for shortcut
  406. * fusion if the section is applied to an array of at least `200` elements
  407. * and any iteratees accept only one argument. The heuristic for whether a
  408. * section qualifies for shortcut fusion is subject to change.
  409. *
  410. * Chaining is supported in custom builds as long as the `_#value` method is
  411. * directly or indirectly included in the build.
  412. *
  413. * In addition to lodash methods, wrappers have `Array` and `String` methods.
  414. *
  415. * The wrapper `Array` methods are:
  416. * `concat`, `join`, `pop`, `push`, `shift`, `sort`, `splice`, and `unshift`
  417. *
  418. * The wrapper `String` methods are:
  419. * `replace` and `split`
  420. *
  421. * The wrapper methods that support shortcut fusion are:
  422. * `at`, `compact`, `drop`, `dropRight`, `dropWhile`, `filter`, `find`,
  423. * `findLast`, `head`, `initial`, `last`, `map`, `reject`, `reverse`, `slice`,
  424. * `tail`, `take`, `takeRight`, `takeRightWhile`, `takeWhile`, and `toArray`
  425. *
  426. * The chainable wrapper methods are:
  427. * `after`, `ary`, `assign`, `assignIn`, `assignInWith`, `assignWith`, `at`,
  428. * `before`, `bind`, `bindAll`, `bindKey`, `castArray`, `chain`, `chunk`,
  429. * `commit`, `compact`, `concat`, `conforms`, `constant`, `countBy`, `create`,
  430. * `curry`, `debounce`, `defaults`, `defaultsDeep`, `defer`, `delay`,
  431. * `difference`, `differenceBy`, `differenceWith`, `drop`, `dropRight`,
  432. * `dropRightWhile`, `dropWhile`, `extend`, `extendWith`, `fill`, `filter`,
  433. * `flatMap`, `flatMapDeep`, `flatMapDepth`, `flatten`, `flattenDeep`,
  434. * `flattenDepth`, `flip`, `flow`, `flowRight`, `fromPairs`, `functions`,
  435. * `functionsIn`, `groupBy`, `initial`, `intersection`, `intersectionBy`,
  436. * `intersectionWith`, `invert`, `invertBy`, `invokeMap`, `iteratee`, `keyBy`,
  437. * `keys`, `keysIn`, `map`, `mapKeys`, `mapValues`, `matches`, `matchesProperty`,
  438. * `memoize`, `merge`, `mergeWith`, `method`, `methodOf`, `mixin`, `negate`,
  439. * `nthArg`, `omit`, `omitBy`, `once`, `orderBy`, `over`, `overArgs`,
  440. * `overEvery`, `overSome`, `partial`, `partialRight`, `partition`, `pick`,
  441. * `pickBy`, `plant`, `property`, `propertyOf`, `pull`, `pullAll`, `pullAllBy`,
  442. * `pullAllWith`, `pullAt`, `push`, `range`, `rangeRight`, `rearg`, `reject`,
  443. * `remove`, `rest`, `reverse`, `sampleSize`, `set`, `setWith`, `shuffle`,
  444. * `slice`, `sort`, `sortBy`, `splice`, `spread`, `tail`, `take`, `takeRight`,
  445. * `takeRightWhile`, `takeWhile`, `tap`, `throttle`, `thru`, `toArray`,
  446. * `toPairs`, `toPairsIn`, `toPath`, `toPlainObject`, `transform`, `unary`,
  447. * `union`, `unionBy`, `unionWith`, `uniq`, `uniqBy`, `uniqWith`, `unset`,
  448. * `unshift`, `unzip`, `unzipWith`, `update`, `updateWith`, `values`,
  449. * `valuesIn`, `without`, `wrap`, `xor`, `xorBy`, `xorWith`, `zip`,
  450. * `zipObject`, `zipObjectDeep`, and `zipWith`
  451. *
  452. * The wrapper methods that are **not** chainable by default are:
  453. * `add`, `attempt`, `camelCase`, `capitalize`, `ceil`, `clamp`, `clone`,
  454. * `cloneDeep`, `cloneDeepWith`, `cloneWith`, `deburr`, `divide`, `each`,
  455. * `eachRight`, `endsWith`, `eq`, `escape`, `escapeRegExp`, `every`, `find`,
  456. * `findIndex`, `findKey`, `findLast`, `findLastIndex`, `findLastKey`, `first`,
  457. * `floor`, `forEach`, `forEachRight`, `forIn`, `forInRight`, `forOwn`,
  458. * `forOwnRight`, `get`, `gt`, `gte`, `has`, `hasIn`, `head`, `identity`,
  459. * `includes`, `indexOf`, `inRange`, `invoke`, `isArguments`, `isArray`,
  460. * `isArrayBuffer`, `isArrayLike`, `isArrayLikeObject`, `isBoolean`,
  461. * `isBuffer`, `isDate`, `isElement`, `isEmpty`, `isEqual`, `isEqualWith`,
  462. * `isError`, `isFinite`, `isFunction`, `isInteger`, `isLength`, `isMap`,
  463. * `isMatch`, `isMatchWith`, `isNaN`, `isNative`, `isNil`, `isNull`, `isNumber`,
  464. * `isObject`, `isObjectLike`, `isPlainObject`, `isRegExp`, `isSafeInteger`,
  465. * `isSet`, `isString`, `isUndefined`, `isTypedArray`, `isWeakMap`, `isWeakSet`,
  466. * `join`, `kebabCase`, `last`, `lastIndexOf`, `lowerCase`, `lowerFirst`,
  467. * `lt`, `lte`, `max`, `maxBy`, `mean`, `meanBy`, `min`, `minBy`, `multiply`,
  468. * `noConflict`, `noop`, `now`, `nth`, `pad`, `padEnd`, `padStart`, `parseInt`,
  469. * `pop`, `random`, `reduce`, `reduceRight`, `repeat`, `result`, `round`,
  470. * `runInContext`, `sample`, `shift`, `size`, `snakeCase`, `some`, `sortedIndex`,
  471. * `sortedIndexBy`, `sortedLastIndex`, `sortedLastIndexBy`, `startCase`,
  472. * `startsWith`, `subtract`, `sum`, `sumBy`, `template`, `times`, `toFinite`,
  473. * `toInteger`, `toJSON`, `toLength`, `toLower`, `toNumber`, `toSafeInteger`,
  474. * `toString`, `toUpper`, `trim`, `trimEnd`, `trimStart`, `truncate`, `unescape`,
  475. * `uniqueId`, `upperCase`, `upperFirst`, `value`, and `words`
  476. *
  477. * @name _
  478. * @constructor
  479. * @category Seq
  480. * @param {*} value The value to wrap in a `lodash` instance.
  481. * @returns {Object} Returns the new `lodash` wrapper instance.
  482. * @example
  483. *
  484. * function square(n) {
  485. * return n * n;
  486. * }
  487. *
  488. * var wrapped = _([1, 2, 3]);
  489. *
  490. * // Returns an unwrapped value.
  491. * wrapped.reduce(_.add);
  492. * // => 6
  493. *
  494. * // Returns a wrapped value.
  495. * var squares = wrapped.map(square);
  496. *
  497. * _.isArray(squares);
  498. * // => false
  499. *
  500. * _.isArray(squares.value());
  501. * // => true
  502. */
  503. function lodash() {
  504. // No operation performed.
  505. }
  506. /*------------------------------------------------------------------------*/
  507. /**
  508. * Creates a hash object.
  509. *
  510. * @private
  511. * @constructor
  512. * @param {Array} [entries] The key-value pairs to cache.
  513. */
  514. function Hash(entries) {
  515. var index = -1,
  516. length = entries ? entries.length : 0;
  517. this.clear();
  518. while (++index < length) {
  519. var entry = entries[index];
  520. this.set(entry[0], entry[1]);
  521. }
  522. }
  523. /**
  524. * Removes all key-value entries from the hash.
  525. *
  526. * @private
  527. * @name clear
  528. * @memberOf Hash
  529. */
  530. function hashClear() {
  531. this.__data__ = nativeCreate ? nativeCreate(null) : {};
  532. }
  533. /**
  534. * Removes `key` and its value from the hash.
  535. *
  536. * @private
  537. * @name delete
  538. * @memberOf Hash
  539. * @param {Object} hash The hash to modify.
  540. * @param {string} key The key of the value to remove.
  541. * @returns {boolean} Returns `true` if the entry was removed, else `false`.
  542. */
  543. function hashDelete(key) {
  544. return this.has(key) && delete this.__data__[key];
  545. }
  546. /**
  547. * Gets the hash value for `key`.
  548. *
  549. * @private
  550. * @name get
  551. * @memberOf Hash
  552. * @param {string} key The key of the value to get.
  553. * @returns {*} Returns the entry value.
  554. */
  555. function hashGet(key) {
  556. var data = this.__data__;
  557. if (nativeCreate) {
  558. var result = data[key];
  559. return result === HASH_UNDEFINED ? undefined : result;
  560. }
  561. return hasOwnProperty.call(data, key) ? data[key] : undefined;
  562. }
  563. /**
  564. * Checks if a hash value for `key` exists.
  565. *
  566. * @private
  567. * @name has
  568. * @memberOf Hash
  569. * @param {string} key The key of the entry to check.
  570. * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
  571. */
  572. function hashHas(key) {
  573. var data = this.__data__;
  574. return nativeCreate ? data[key] !== undefined : hasOwnProperty.call(data, key);
  575. }
  576. /**
  577. * Sets the hash `key` to `value`.
  578. *
  579. * @private
  580. * @name set
  581. * @memberOf Hash
  582. * @param {string} key The key of the value to set.
  583. * @param {*} value The value to set.
  584. * @returns {Object} Returns the hash instance.
  585. */
  586. function hashSet(key, value) {
  587. var data = this.__data__;
  588. data[key] = (nativeCreate && value === undefined) ? HASH_UNDEFINED : value;
  589. return this;
  590. }
  591. // Add methods to `Hash`.
  592. Hash.prototype.clear = hashClear;
  593. Hash.prototype['delete'] = hashDelete;
  594. Hash.prototype.get = hashGet;
  595. Hash.prototype.has = hashHas;
  596. Hash.prototype.set = hashSet;
  597. /*------------------------------------------------------------------------*/
  598. /**
  599. * Creates an list cache object.
  600. *
  601. * @private
  602. * @constructor
  603. * @param {Array} [entries] The key-value pairs to cache.
  604. */
  605. function ListCache(entries) {
  606. var index = -1,
  607. length = entries ? entries.length : 0;
  608. this.clear();
  609. while (++index < length) {
  610. var entry = entries[index];
  611. this.set(entry[0], entry[1]);
  612. }
  613. }
  614. /**
  615. * Removes all key-value entries from the list cache.
  616. *
  617. * @private
  618. * @name clear
  619. * @memberOf ListCache
  620. */
  621. function listCacheClear() {
  622. this.__data__ = [];
  623. }
  624. /**
  625. * Removes `key` and its value from the list cache.
  626. *
  627. * @private
  628. * @name delete
  629. * @memberOf ListCache
  630. * @param {string} key The key of the value to remove.
  631. * @returns {boolean} Returns `true` if the entry was removed, else `false`.
  632. */
  633. function listCacheDelete(key) {
  634. var data = this.__data__,
  635. index = assocIndexOf(data, key);
  636. if (index < 0) {
  637. return false;
  638. }
  639. var lastIndex = data.length - 1;
  640. if (index == lastIndex) {
  641. data.pop();
  642. } else {
  643. splice.call(data, index, 1);
  644. }
  645. return true;
  646. }
  647. /**
  648. * Gets the list cache value for `key`.
  649. *
  650. * @private
  651. * @name get
  652. * @memberOf ListCache
  653. * @param {string} key The key of the value to get.
  654. * @returns {*} Returns the entry value.
  655. */
  656. function listCacheGet(key) {
  657. var data = this.__data__,
  658. index = assocIndexOf(data, key);
  659. return index < 0 ? undefined : data[index][1];
  660. }
  661. /**
  662. * Checks if a list cache value for `key` exists.
  663. *
  664. * @private
  665. * @name has
  666. * @memberOf ListCache
  667. * @param {string} key The key of the entry to check.
  668. * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
  669. */
  670. function listCacheHas(key) {
  671. return assocIndexOf(this.__data__, key) > -1;
  672. }
  673. /**
  674. * Sets the list cache `key` to `value`.
  675. *
  676. * @private
  677. * @name set
  678. * @memberOf ListCache
  679. * @param {string} key The key of the value to set.
  680. * @param {*} value The value to set.
  681. * @returns {Object} Returns the list cache instance.
  682. */
  683. function listCacheSet(key, value) {
  684. var data = this.__data__,
  685. index = assocIndexOf(data, key);
  686. if (index < 0) {
  687. data.push([key, value]);
  688. } else {
  689. data[index][1] = value;
  690. }
  691. return this;
  692. }
  693. // Add methods to `ListCache`.
  694. ListCache.prototype.clear = listCacheClear;
  695. ListCache.prototype['delete'] = listCacheDelete;
  696. ListCache.prototype.get = listCacheGet;
  697. ListCache.prototype.has = listCacheHas;
  698. ListCache.prototype.set = listCacheSet;
  699. /*------------------------------------------------------------------------*/
  700. /**
  701. * Creates a map cache object to store key-value pairs.
  702. *
  703. * @private
  704. * @constructor
  705. * @param {Array} [entries] The key-value pairs to cache.
  706. */
  707. function MapCache(entries) {
  708. var index = -1,
  709. length = entries ? entries.length : 0;
  710. this.clear();
  711. while (++index < length) {
  712. var entry = entries[index];
  713. this.set(entry[0], entry[1]);
  714. }
  715. }
  716. /**
  717. * Removes all key-value entries from the map.
  718. *
  719. * @private
  720. * @name clear
  721. * @memberOf MapCache
  722. */
  723. function mapCacheClear() {
  724. this.__data__ = {
  725. 'hash': new Hash,
  726. 'map': new (Map || ListCache),
  727. 'string': new Hash
  728. };
  729. }
  730. /**
  731. * Removes `key` and its value from the map.
  732. *
  733. * @private
  734. * @name delete
  735. * @memberOf MapCache
  736. * @param {string} key The key of the value to remove.
  737. * @returns {boolean} Returns `true` if the entry was removed, else `false`.
  738. */
  739. function mapCacheDelete(key) {
  740. return getMapData(this, key)['delete'](key);
  741. }
  742. /**
  743. * Gets the map value for `key`.
  744. *
  745. * @private
  746. * @name get
  747. * @memberOf MapCache
  748. * @param {string} key The key of the value to get.
  749. * @returns {*} Returns the entry value.
  750. */
  751. function mapCacheGet(key) {
  752. return getMapData(this, key).get(key);
  753. }
  754. /**
  755. * Checks if a map value for `key` exists.
  756. *
  757. * @private
  758. * @name has
  759. * @memberOf MapCache
  760. * @param {string} key The key of the entry to check.
  761. * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
  762. */
  763. function mapCacheHas(key) {
  764. return getMapData(this, key).has(key);
  765. }
  766. /**
  767. * Sets the map `key` to `value`.
  768. *
  769. * @private
  770. * @name set
  771. * @memberOf MapCache
  772. * @param {string} key The key of the value to set.
  773. * @param {*} value The value to set.
  774. * @returns {Object} Returns the map cache instance.
  775. */
  776. function mapCacheSet(key, value) {
  777. getMapData(this, key).set(key, value);
  778. return this;
  779. }
  780. // Add methods to `MapCache`.
  781. MapCache.prototype.clear = mapCacheClear;
  782. MapCache.prototype['delete'] = mapCacheDelete;
  783. MapCache.prototype.get = mapCacheGet;
  784. MapCache.prototype.has = mapCacheHas;
  785. MapCache.prototype.set = mapCacheSet;
  786. /*------------------------------------------------------------------------*/
  787. /**
  788. * Creates a stack cache object to store key-value pairs.
  789. *
  790. * @private
  791. * @constructor
  792. * @param {Array} [entries] The key-value pairs to cache.
  793. */
  794. function Stack(entries) {
  795. this.__data__ = new ListCache(entries);
  796. }
  797. /**
  798. * Removes all key-value entries from the stack.
  799. *
  800. * @private
  801. * @name clear
  802. * @memberOf Stack
  803. */
  804. function stackClear() {
  805. this.__data__ = new ListCache;
  806. }
  807. /**
  808. * Removes `key` and its value from the stack.
  809. *
  810. * @private
  811. * @name delete
  812. * @memberOf Stack
  813. * @param {string} key The key of the value to remove.
  814. * @returns {boolean} Returns `true` if the entry was removed, else `false`.
  815. */
  816. function stackDelete(key) {
  817. return this.__data__['delete'](key);
  818. }
  819. /**
  820. * Gets the stack value for `key`.
  821. *
  822. * @private
  823. * @name get
  824. * @memberOf Stack
  825. * @param {string} key The key of the value to get.
  826. * @returns {*} Returns the entry value.
  827. */
  828. function stackGet(key) {
  829. return this.__data__.get(key);
  830. }
  831. /**
  832. * Checks if a stack value for `key` exists.
  833. *
  834. * @private
  835. * @name has
  836. * @memberOf Stack
  837. * @param {string} key The key of the entry to check.
  838. * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
  839. */
  840. function stackHas(key) {
  841. return this.__data__.has(key);
  842. }
  843. /**
  844. * Sets the stack `key` to `value`.
  845. *
  846. * @private
  847. * @name set
  848. * @memberOf Stack
  849. * @param {string} key The key of the value to set.
  850. * @param {*} value The value to set.
  851. * @returns {Object} Returns the stack cache instance.
  852. */
  853. function stackSet(key, value) {
  854. var cache = this.__data__;
  855. if (cache instanceof ListCache && cache.__data__.length == LARGE_ARRAY_SIZE) {
  856. cache = this.__data__ = new MapCache(cache.__data__);
  857. }
  858. cache.set(key, value);
  859. return this;
  860. }
  861. // Add methods to `Stack`.
  862. Stack.prototype.clear = stackClear;
  863. Stack.prototype['delete'] = stackDelete;
  864. Stack.prototype.get = stackGet;
  865. Stack.prototype.has = stackHas;
  866. Stack.prototype.set = stackSet;
  867. /*------------------------------------------------------------------------*/
  868. /**
  869. * This function is like `assignValue` except that it doesn't assign
  870. * `undefined` values.
  871. *
  872. * @private
  873. * @param {Object} object The object to modify.
  874. * @param {string} key The key of the property to assign.
  875. * @param {*} value The value to assign.
  876. */
  877. function assignMergeValue(object, key, value) {
  878. if ((value !== undefined && !eq(object[key], value)) ||
  879. (typeof key == 'number' && value === undefined && !(key in object))) {
  880. object[key] = value;
  881. }
  882. }
  883. /**
  884. * Assigns `value` to `key` of `object` if the existing value is not equivalent
  885. * using [`SameValueZero`](http://ecma-international.org/ecma-262/6.0/#sec-samevaluezero)
  886. * for equality comparisons.
  887. *
  888. * @private
  889. * @param {Object} object The object to modify.
  890. * @param {string} key The key of the property to assign.
  891. * @param {*} value The value to assign.
  892. */
  893. function assignValue(object, key, value) {
  894. var objValue = object[key];
  895. if (!(hasOwnProperty.call(object, key) && eq(objValue, value)) ||
  896. (value === undefined && !(key in object))) {
  897. object[key] = value;
  898. }
  899. }
  900. /**
  901. * Gets the index at which the `key` is found in `array` of key-value pairs.
  902. *
  903. * @private
  904. * @param {Array} array The array to search.
  905. * @param {*} key The key to search for.
  906. * @returns {number} Returns the index of the matched value, else `-1`.
  907. */
  908. function assocIndexOf(array, key) {
  909. var length = array.length;
  910. while (length--) {
  911. if (eq(array[length][0], key)) {
  912. return length;
  913. }
  914. }
  915. return -1;
  916. }
  917. /**
  918. * The base implementation of `_.assign` without support for multiple sources
  919. * or `customizer` functions.
  920. *
  921. * @private
  922. * @param {Object} object The destination object.
  923. * @param {Object} source The source object.
  924. * @returns {Object} Returns `object`.
  925. */
  926. function baseAssign(object, source) {
  927. return object && copyObject(source, keys(source), object);
  928. }
  929. /**
  930. * The base implementation of `_.clone` and `_.cloneDeep` which tracks
  931. * traversed objects.
  932. *
  933. * @private
  934. * @param {*} value The value to clone.
  935. * @param {boolean} [isDeep] Specify a deep clone.
  936. * @param {boolean} [isFull] Specify a clone including symbols.
  937. * @param {Function} [customizer] The function to customize cloning.
  938. * @param {string} [key] The key of `value`.
  939. * @param {Object} [object] The parent object of `value`.
  940. * @param {Object} [stack] Tracks traversed objects and their clone counterparts.
  941. * @returns {*} Returns the cloned value.
  942. */
  943. function baseClone(value, isDeep, isFull, customizer, key, object, stack) {
  944. var result;
  945. if (customizer) {
  946. result = object ? customizer(value, key, object, stack) : customizer(value);
  947. }
  948. if (result !== undefined) {
  949. return result;
  950. }
  951. if (!isObject(value)) {
  952. return value;
  953. }
  954. var isArr = isArray(value);
  955. if (isArr) {
  956. result = initCloneArray(value);
  957. if (!isDeep) {
  958. return copyArray(value, result);
  959. }
  960. } else {
  961. var tag = getTag(value),
  962. isFunc = tag == funcTag || tag == genTag;
  963. if (isBuffer(value)) {
  964. return cloneBuffer(value, isDeep);
  965. }
  966. if (tag == objectTag || tag == argsTag || (isFunc && !object)) {
  967. if (isHostObject(value)) {
  968. return object ? value : {};
  969. }
  970. result = initCloneObject(isFunc ? {} : value);
  971. if (!isDeep) {
  972. return copySymbols(value, baseAssign(result, value));
  973. }
  974. } else {
  975. if (!cloneableTags[tag]) {
  976. return object ? value : {};
  977. }
  978. result = initCloneByTag(value, tag, baseClone, isDeep);
  979. }
  980. }
  981. // Check for circular references and return its corresponding clone.
  982. stack || (stack = new Stack);
  983. var stacked = stack.get(value);
  984. if (stacked) {
  985. return stacked;
  986. }
  987. stack.set(value, result);
  988. if (!isArr) {
  989. var props = isFull ? getAllKeys(value) : keys(value);
  990. }
  991. // Recursively populate clone (susceptible to call stack limits).
  992. arrayEach(props || value, function(subValue, key) {
  993. if (props) {
  994. key = subValue;
  995. subValue = value[key];
  996. }
  997. assignValue(result, key, baseClone(subValue, isDeep, isFull, customizer, key, value, stack));
  998. });
  999. return result;
  1000. }
  1001. /**
  1002. * The base implementation of `_.create` without support for assigning
  1003. * properties to the created object.
  1004. *
  1005. * @private
  1006. * @param {Object} prototype The object to inherit from.
  1007. * @returns {Object} Returns the new object.
  1008. */
  1009. function baseCreate(proto) {
  1010. return isObject(proto) ? objectCreate(proto) : {};
  1011. }
  1012. /**
  1013. * The base implementation of `getAllKeys` and `getAllKeysIn` which uses
  1014. * `keysFunc` and `symbolsFunc` to get the enumerable property names and
  1015. * symbols of `object`.
  1016. *
  1017. * @private
  1018. * @param {Object} object The object to query.
  1019. * @param {Function} keysFunc The function to get the keys of `object`.
  1020. * @param {Function} symbolsFunc The function to get the symbols of `object`.
  1021. * @returns {Array} Returns the array of property names and symbols.
  1022. */
  1023. function baseGetAllKeys(object, keysFunc, symbolsFunc) {
  1024. var result = keysFunc(object);
  1025. return isArray(object) ? result : arrayPush(result, symbolsFunc(object));
  1026. }
  1027. /**
  1028. * The base implementation of `_.has` without support for deep paths.
  1029. *
  1030. * @private
  1031. * @param {Object} object The object to query.
  1032. * @param {Array|string} key The key to check.
  1033. * @returns {boolean} Returns `true` if `key` exists, else `false`.
  1034. */
  1035. function baseHas(object, key) {
  1036. // Avoid a bug in IE 10-11 where objects with a [[Prototype]] of `null`,
  1037. // that are composed entirely of index properties, return `false` for
  1038. // `hasOwnProperty` checks of them.
  1039. return hasOwnProperty.call(object, key) ||
  1040. (typeof object == 'object' && key in object && getPrototype(object) === null);
  1041. }
  1042. /**
  1043. * The base implementation of `_.keys` which doesn't skip the constructor
  1044. * property of prototypes or treat sparse arrays as dense.
  1045. *
  1046. * @private
  1047. * @param {Object} object The object to query.
  1048. * @returns {Array} Returns the array of property names.
  1049. */
  1050. function baseKeys(object) {
  1051. return nativeKeys(Object(object));
  1052. }
  1053. /**
  1054. * The base implementation of `_.keysIn` which doesn't skip the constructor
  1055. * property of prototypes or treat sparse arrays as dense.
  1056. *
  1057. * @private
  1058. * @param {Object} object The object to query.
  1059. * @returns {Array} Returns the array of property names.
  1060. */
  1061. function baseKeysIn(object) {
  1062. object = object == null ? object : Object(object);
  1063. var result = [];
  1064. for (var key in object) {
  1065. result.push(key);
  1066. }
  1067. return result;
  1068. }
  1069. // Fallback for IE < 9 with es6-shim.
  1070. if (enumerate && !propertyIsEnumerable.call({ 'valueOf': 1 }, 'valueOf')) {
  1071. baseKeysIn = function(object) {
  1072. return iteratorToArray(enumerate(object));
  1073. };
  1074. }
  1075. /**
  1076. * The base implementation of `_.merge` without support for multiple sources.
  1077. *
  1078. * @private
  1079. * @param {Object} object The destination object.
  1080. * @param {Object} source The source object.
  1081. * @param {number} srcIndex The index of `source`.
  1082. * @param {Function} [customizer] The function to customize merged values.
  1083. * @param {Object} [stack] Tracks traversed source values and their merged
  1084. * counterparts.
  1085. */
  1086. function baseMerge(object, source, srcIndex, customizer, stack) {
  1087. if (object === source) {
  1088. return;
  1089. }
  1090. if (!(isArray(source) || isTypedArray(source))) {
  1091. var props = keysIn(source);
  1092. }
  1093. arrayEach(props || source, function(srcValue, key) {
  1094. if (props) {
  1095. key = srcValue;
  1096. srcValue = source[key];
  1097. }
  1098. if (isObject(srcValue)) {
  1099. stack || (stack = new Stack);
  1100. baseMergeDeep(object, source, key, srcIndex, baseMerge, customizer, stack);
  1101. }
  1102. else {
  1103. var newValue = customizer
  1104. ? customizer(object[key], srcValue, (key + ''), object, source, stack)
  1105. : undefined;
  1106. if (newValue === undefined) {
  1107. newValue = srcValue;
  1108. }
  1109. assignMergeValue(object, key, newValue);
  1110. }
  1111. });
  1112. }
  1113. /**
  1114. * A specialized version of `baseMerge` for arrays and objects which performs
  1115. * deep merges and tracks traversed objects enabling objects with circular
  1116. * references to be merged.
  1117. *
  1118. * @private
  1119. * @param {Object} object The destination object.
  1120. * @param {Object} source The source object.
  1121. * @param {string} key The key of the value to merge.
  1122. * @param {number} srcIndex The index of `source`.
  1123. * @param {Function} mergeFunc The function to merge values.
  1124. * @param {Function} [customizer] The function to customize assigned values.
  1125. * @param {Object} [stack] Tracks traversed source values and their merged
  1126. * counterparts.
  1127. */
  1128. function baseMergeDeep(object, source, key, srcIndex, mergeFunc, customizer, stack) {
  1129. var objValue = object[key],
  1130. srcValue = source[key],
  1131. stacked = stack.get(srcValue);
  1132. if (stacked) {
  1133. assignMergeValue(object, key, stacked);
  1134. return;
  1135. }
  1136. var newValue = customizer
  1137. ? customizer(objValue, srcValue, (key + ''), object, source, stack)
  1138. : undefined;
  1139. var isCommon = newValue === undefined;
  1140. if (isCommon) {
  1141. newValue = srcValue;
  1142. if (isArray(srcValue) || isTypedArray(srcValue)) {
  1143. if (isArray(objValue)) {
  1144. newValue = objValue;
  1145. }
  1146. else if (isArrayLikeObject(objValue)) {
  1147. newValue = copyArray(objValue);
  1148. }
  1149. else {
  1150. isCommon = false;
  1151. newValue = baseClone(srcValue, true);
  1152. }
  1153. }
  1154. else if (isPlainObject(srcValue) || isArguments(srcValue)) {
  1155. if (isArguments(objValue)) {
  1156. newValue = toPlainObject(objValue);
  1157. }
  1158. else if (!isObject(objValue) || (srcIndex && isFunction(objValue))) {
  1159. isCommon = false;
  1160. newValue = baseClone(srcValue, true);
  1161. }
  1162. else {
  1163. newValue = objValue;
  1164. }
  1165. }
  1166. else {
  1167. isCommon = false;
  1168. }
  1169. }
  1170. stack.set(srcValue, newValue);
  1171. if (isCommon) {
  1172. // Recursively merge objects and arrays (susceptible to call stack limits).
  1173. mergeFunc(newValue, srcValue, srcIndex, customizer, stack);
  1174. }
  1175. stack['delete'](srcValue);
  1176. assignMergeValue(object, key, newValue);
  1177. }
  1178. /**
  1179. * The base implementation of `_.property` without support for deep paths.
  1180. *
  1181. * @private
  1182. * @param {string} key The key of the property to get.
  1183. * @returns {Function} Returns the new accessor function.
  1184. */
  1185. function baseProperty(key) {
  1186. return function(object) {
  1187. return object == null ? undefined : object[key];
  1188. };
  1189. }
  1190. /**
  1191. * Creates a clone of `buffer`.
  1192. *
  1193. * @private
  1194. * @param {Buffer} buffer The buffer to clone.
  1195. * @param {boolean} [isDeep] Specify a deep clone.
  1196. * @returns {Buffer} Returns the cloned buffer.
  1197. */
  1198. function cloneBuffer(buffer, isDeep) {
  1199. if (isDeep) {
  1200. return buffer.slice();
  1201. }
  1202. var result = new buffer.constructor(buffer.length);
  1203. buffer.copy(result);
  1204. return result;
  1205. }
  1206. /**
  1207. * Creates a clone of `arrayBuffer`.
  1208. *
  1209. * @private
  1210. * @param {ArrayBuffer} arrayBuffer The array buffer to clone.
  1211. * @returns {ArrayBuffer} Returns the cloned array buffer.
  1212. */
  1213. function cloneArrayBuffer(arrayBuffer) {
  1214. var result = new arrayBuffer.constructor(arrayBuffer.byteLength);
  1215. new Uint8Array(result).set(new Uint8Array(arrayBuffer));
  1216. return result;
  1217. }
  1218. /**
  1219. * Creates a clone of `dataView`.
  1220. *
  1221. * @private
  1222. * @param {Object} dataView The data view to clone.
  1223. * @param {boolean} [isDeep] Specify a deep clone.
  1224. * @returns {Object} Returns the cloned data view.
  1225. */
  1226. function cloneDataView(dataView, isDeep) {
  1227. var buffer = isDeep ? cloneArrayBuffer(dataView.buffer) : dataView.buffer;
  1228. return new dataView.constructor(buffer, dataView.byteOffset, dataView.byteLength);
  1229. }
  1230. /**
  1231. * Creates a clone of `map`.
  1232. *
  1233. * @private
  1234. * @param {Object} map The map to clone.
  1235. * @param {Function} cloneFunc The function to clone values.
  1236. * @param {boolean} [isDeep] Specify a deep clone.
  1237. * @returns {Object} Returns the cloned map.
  1238. */
  1239. function cloneMap(map, isDeep, cloneFunc) {
  1240. var array = isDeep ? cloneFunc(mapToArray(map), true) : mapToArray(map);
  1241. return arrayReduce(array, addMapEntry, new map.constructor);
  1242. }
  1243. /**
  1244. * Creates a clone of `regexp`.
  1245. *
  1246. * @private
  1247. * @param {Object} regexp The regexp to clone.
  1248. * @returns {Object} Returns the cloned regexp.
  1249. */
  1250. function cloneRegExp(regexp) {
  1251. var result = new regexp.constructor(regexp.source, reFlags.exec(regexp));
  1252. result.lastIndex = regexp.lastIndex;
  1253. return result;
  1254. }
  1255. /**
  1256. * Creates a clone of `set`.
  1257. *
  1258. * @private
  1259. * @param {Object} set The set to clone.
  1260. * @param {Function} cloneFunc The function to clone values.
  1261. * @param {boolean} [isDeep] Specify a deep clone.
  1262. * @returns {Object} Returns the cloned set.
  1263. */
  1264. function cloneSet(set, isDeep, cloneFunc) {
  1265. var array = isDeep ? cloneFunc(setToArray(set), true) : setToArray(set);
  1266. return arrayReduce(array, addSetEntry, new set.constructor);
  1267. }
  1268. /**
  1269. * Creates a clone of the `symbol` object.
  1270. *
  1271. * @private
  1272. * @param {Object} symbol The symbol object to clone.
  1273. * @returns {Object} Returns the cloned symbol object.
  1274. */
  1275. function cloneSymbol(symbol) {
  1276. return symbolValueOf ? Object(symbolValueOf.call(symbol)) : {};
  1277. }
  1278. /**
  1279. * Creates a clone of `typedArray`.
  1280. *
  1281. * @private
  1282. * @param {Object} typedArray The typed array to clone.
  1283. * @param {boolean} [isDeep] Specify a deep clone.
  1284. * @returns {Object} Returns the cloned typed array.
  1285. */
  1286. function cloneTypedArray(typedArray, isDeep) {
  1287. var buffer = isDeep ? cloneArrayBuffer(typedArray.buffer) : typedArray.buffer;
  1288. return new typedArray.constructor(buffer, typedArray.byteOffset, typedArray.length);
  1289. }
  1290. /**
  1291. * Copies the values of `source` to `array`.
  1292. *
  1293. * @private
  1294. * @param {Array} source The array to copy values from.
  1295. * @param {Array} [array=[]] The array to copy values to.
  1296. * @returns {Array} Returns `array`.
  1297. */
  1298. function copyArray(source, array) {
  1299. var index = -1,
  1300. length = source.length;
  1301. array || (array = Array(length));
  1302. while (++index < length) {
  1303. array[index] = source[index];
  1304. }
  1305. return array;
  1306. }
  1307. /**
  1308. * Copies properties of `source` to `object`.
  1309. *
  1310. * @private
  1311. * @param {Object} source The object to copy properties from.
  1312. * @param {Array} props The property identifiers to copy.
  1313. * @param {Object} [object={}] The object to copy properties to.
  1314. * @param {Function} [customizer] The function to customize copied values.
  1315. * @returns {Object} Returns `object`.
  1316. */
  1317. function copyObject(source, props, object, customizer) {
  1318. object || (object = {});
  1319. var index = -1,
  1320. length = props.length;
  1321. while (++index < length) {
  1322. var key = props[index];
  1323. var newValue = customizer
  1324. ? customizer(object[key], source[key], key, object, source)
  1325. : source[key];
  1326. assignValue(object, key, newValue);
  1327. }
  1328. return object;
  1329. }
  1330. /**
  1331. * Copies own symbol properties of `source` to `object`.
  1332. *
  1333. * @private
  1334. * @param {Object} source The object to copy symbols from.
  1335. * @param {Object} [object={}] The object to copy symbols to.
  1336. * @returns {Object} Returns `object`.
  1337. */
  1338. function copySymbols(source, object) {
  1339. return copyObject(source, getSymbols(source), object);
  1340. }
  1341. /**
  1342. * Creates a function like `_.assign`.
  1343. *
  1344. * @private
  1345. * @param {Function} assigner The function to assign values.
  1346. * @returns {Function} Returns the new assigner function.
  1347. */
  1348. function createAssigner(assigner) {
  1349. return rest(function(object, sources) {
  1350. var index = -1,
  1351. length = sources.length,
  1352. customizer = length > 1 ? sources[length - 1] : undefined,
  1353. guard = length > 2 ? sources[2] : undefined;
  1354. customizer = (assigner.length > 3 && typeof customizer == 'function')
  1355. ? (length--, customizer)
  1356. : undefined;
  1357. if (guard && isIterateeCall(sources[0], sources[1], guard)) {
  1358. customizer = length < 3 ? undefined : customizer;
  1359. length = 1;
  1360. }
  1361. object = Object(object);
  1362. while (++index < length) {
  1363. var source = sources[index];
  1364. if (source) {
  1365. assigner(object, source, index, customizer);
  1366. }
  1367. }
  1368. return object;
  1369. });
  1370. }
  1371. /**
  1372. * Creates an array of own enumerable property names and symbols of `object`.
  1373. *
  1374. * @private
  1375. * @param {Object} object The object to query.
  1376. * @returns {Array} Returns the array of property names and symbols.
  1377. */
  1378. function getAllKeys(object) {
  1379. return baseGetAllKeys(object, keys, getSymbols);
  1380. }
  1381. /**
  1382. * Gets the "length" property value of `object`.
  1383. *
  1384. * **Note:** This function is used to avoid a
  1385. * [JIT bug](https://bugs.webkit.org/show_bug.cgi?id=142792) that affects
  1386. * Safari on at least iOS 8.1-8.3 ARM64.
  1387. *
  1388. * @private
  1389. * @param {Object} object The object to query.
  1390. * @returns {*} Returns the "length" value.
  1391. */
  1392. var getLength = baseProperty('length');
  1393. /**
  1394. * Gets the data for `map`.
  1395. *
  1396. * @private
  1397. * @param {Object} map The map to query.
  1398. * @param {string} key The reference key.
  1399. * @returns {*} Returns the map data.
  1400. */
  1401. function getMapData(map, key) {
  1402. var data = map.__data__;
  1403. return isKeyable(key)
  1404. ? data[typeof key == 'string' ? 'string' : 'hash']
  1405. : data.map;
  1406. }
  1407. /**
  1408. * Gets the native function at `key` of `object`.
  1409. *
  1410. * @private
  1411. * @param {Object} object The object to query.
  1412. * @param {string} key The key of the method to get.
  1413. * @returns {*} Returns the function if it's native, else `undefined`.
  1414. */
  1415. function getNative(object, key) {
  1416. var value = object[key];
  1417. return isNative(value) ? value : undefined;
  1418. }
  1419. /**
  1420. * Gets the `[[Prototype]]` of `value`.
  1421. *
  1422. * @private
  1423. * @param {*} value The value to query.
  1424. * @returns {null|Object} Returns the `[[Prototype]]`.
  1425. */
  1426. function getPrototype(value) {
  1427. return nativeGetPrototype(Object(value));
  1428. }
  1429. /**
  1430. * Creates an array of the own enumerable symbol properties of `object`.
  1431. *
  1432. * @private
  1433. * @param {Object} object The object to query.
  1434. * @returns {Array} Returns the array of symbols.
  1435. */
  1436. function getSymbols(object) {
  1437. // Coerce `object` to an object to avoid non-object errors in V8.
  1438. // See https://bugs.chromium.org/p/v8/issues/detail?id=3443 for more details.
  1439. return getOwnPropertySymbols(Object(object));
  1440. }
  1441. // Fallback for IE < 11.
  1442. if (!getOwnPropertySymbols) {
  1443. getSymbols = function() {
  1444. return [];
  1445. };
  1446. }
  1447. /**
  1448. * Gets the `toStringTag` of `value`.
  1449. *
  1450. * @private
  1451. * @param {*} value The value to query.
  1452. * @returns {string} Returns the `toStringTag`.
  1453. */
  1454. function getTag(value) {
  1455. return objectToString.call(value);
  1456. }
  1457. // Fallback for data views, maps, sets, and weak maps in IE 11,
  1458. // for data views in Edge, and promises in Node.js.
  1459. if ((DataView && getTag(new DataView(new ArrayBuffer(1))) != dataViewTag) ||
  1460. (Map && getTag(new Map) != mapTag) ||
  1461. (Promise && getTag(Promise.resolve()) != promiseTag) ||
  1462. (Set && getTag(new Set) != setTag) ||
  1463. (WeakMap && getTag(new WeakMap) != weakMapTag)) {
  1464. getTag = function(value) {
  1465. var result = objectToString.call(value),
  1466. Ctor = result == objectTag ? value.constructor : undefined,
  1467. ctorString = Ctor ? toSource(Ctor) : undefined;
  1468. if (ctorString) {
  1469. switch (ctorString) {
  1470. case dataViewCtorString: return dataViewTag;
  1471. case mapCtorString: return mapTag;
  1472. case promiseCtorString: return promiseTag;
  1473. case setCtorString: return setTag;
  1474. case weakMapCtorString: return weakMapTag;
  1475. }
  1476. }
  1477. return result;
  1478. };
  1479. }
  1480. /**
  1481. * Initializes an array clone.
  1482. *
  1483. * @private
  1484. * @param {Array} array The array to clone.
  1485. * @returns {Array} Returns the initialized clone.
  1486. */
  1487. function initCloneArray(array) {
  1488. var length = array.length,
  1489. result = array.constructor(length);
  1490. // Add properties assigned by `RegExp#exec`.
  1491. if (length && typeof array[0] == 'string' && hasOwnProperty.call(array, 'index')) {
  1492. result.index = array.index;
  1493. result.input = array.input;
  1494. }
  1495. return result;
  1496. }
  1497. /**
  1498. * Initializes an object clone.
  1499. *
  1500. * @private
  1501. * @param {Object} object The object to clone.
  1502. * @returns {Object} Returns the initialized clone.
  1503. */
  1504. function initCloneObject(object) {
  1505. return (typeof object.constructor == 'function' && !isPrototype(object))
  1506. ? baseCreate(getPrototype(object))
  1507. : {};
  1508. }
  1509. /**
  1510. * Initializes an object clone based on its `toStringTag`.
  1511. *
  1512. * **Note:** This function only supports cloning values with tags of
  1513. * `Boolean`, `Date`, `Error`, `Number`, `RegExp`, or `String`.
  1514. *
  1515. * @private
  1516. * @param {Object} object The object to clone.
  1517. * @param {string} tag The `toStringTag` of the object to clone.
  1518. * @param {Function} cloneFunc The function to clone values.
  1519. * @param {boolean} [isDeep] Specify a deep clone.
  1520. * @returns {Object} Returns the initialized clone.
  1521. */
  1522. function initCloneByTag(object, tag, cloneFunc, isDeep) {
  1523. var Ctor = object.constructor;
  1524. switch (tag) {
  1525. case arrayBufferTag:
  1526. return cloneArrayBuffer(object);
  1527. case boolTag:
  1528. case dateTag:
  1529. return new Ctor(+object);
  1530. case dataViewTag:
  1531. return cloneDataView(object, isDeep);
  1532. case float32Tag: case float64Tag:
  1533. case int8Tag: case int16Tag: case int32Tag:
  1534. case uint8Tag: case uint8ClampedTag: case uint16Tag: case uint32Tag:
  1535. return cloneTypedArray(object, isDeep);
  1536. case mapTag:
  1537. return cloneMap(object, isDeep, cloneFunc);
  1538. case numberTag:
  1539. case stringTag:
  1540. return new Ctor(object);
  1541. case regexpTag:
  1542. return cloneRegExp(object);
  1543. case setTag:
  1544. return cloneSet(object, isDeep, cloneFunc);
  1545. case symbolTag:
  1546. return cloneSymbol(object);
  1547. }
  1548. }
  1549. /**
  1550. * Creates an array of index keys for `object` values of arrays,
  1551. * `arguments` objects, and strings, otherwise `null` is returned.
  1552. *
  1553. * @private
  1554. * @param {Object} object The object to query.
  1555. * @returns {Array|null} Returns index keys, else `null`.
  1556. */
  1557. function indexKeys(object) {
  1558. var length = object ? object.length : undefined;
  1559. if (isLength(length) &&
  1560. (isArray(object) || isString(object) || isArguments(object))) {
  1561. return baseTimes(length, String);
  1562. }
  1563. return null;
  1564. }
  1565. /**
  1566. * Checks if `value` is a valid array-like index.
  1567. *
  1568. * @private
  1569. * @param {*} value The value to check.
  1570. * @param {number} [length=MAX_SAFE_INTEGER] The upper bounds of a valid index.
  1571. * @returns {boolean} Returns `true` if `value` is a valid index, else `false`.
  1572. */
  1573. function isIndex(value, length) {
  1574. length = length == null ? MAX_SAFE_INTEGER : length;
  1575. return !!length &&
  1576. (typeof value == 'number' || reIsUint.test(value)) &&
  1577. (value > -1 && value % 1 == 0 && value < length);
  1578. }
  1579. /**
  1580. * Checks if the given arguments are from an iteratee call.
  1581. *
  1582. * @private
  1583. * @param {*} value The potential iteratee value argument.
  1584. * @param {*} index The potential iteratee index or key argument.
  1585. * @param {*} object The potential iteratee object argument.
  1586. * @returns {boolean} Returns `true` if the arguments are from an iteratee call,
  1587. * else `false`.
  1588. */
  1589. function isIterateeCall(value, index, object) {
  1590. if (!isObject(object)) {
  1591. return false;
  1592. }
  1593. var type = typeof index;
  1594. if (type == 'number'
  1595. ? (isArrayLike(object) && isIndex(index, object.length))
  1596. : (type == 'string' && index in object)
  1597. ) {
  1598. return eq(object[index], value);
  1599. }
  1600. return false;
  1601. }
  1602. /**
  1603. * Checks if `value` is suitable for use as unique object key.
  1604. *
  1605. * @private
  1606. * @param {*} value The value to check.
  1607. * @returns {boolean} Returns `true` if `value` is suitable, else `false`.
  1608. */
  1609. function isKeyable(value) {
  1610. var type = typeof value;
  1611. return (type == 'string' || type == 'number' || type == 'symbol' || type == 'boolean')
  1612. ? (value !== '__proto__')
  1613. : (value === null);
  1614. }
  1615. /**
  1616. * Checks if `value` is likely a prototype object.
  1617. *
  1618. * @private
  1619. * @param {*} value The value to check.
  1620. * @returns {boolean} Returns `true` if `value` is a prototype, else `false`.
  1621. */
  1622. function isPrototype(value) {
  1623. var Ctor = value && value.constructor,
  1624. proto = (typeof Ctor == 'function' && Ctor.prototype) || objectProto;
  1625. return value === proto;
  1626. }
  1627. /**
  1628. * Converts `func` to its source code.
  1629. *
  1630. * @private
  1631. * @param {Function} func The function to process.
  1632. * @returns {string} Returns the source code.
  1633. */
  1634. function toSource(func) {
  1635. if (func != null) {
  1636. try {
  1637. return funcToString.call(func);
  1638. } catch (e) {}
  1639. try {
  1640. return (func + '');
  1641. } catch (e) {}
  1642. }
  1643. return '';
  1644. }
  1645. /*------------------------------------------------------------------------*/
  1646. /**
  1647. * Creates a function that invokes `func` with the `this` binding of the
  1648. * created function and arguments from `start` and beyond provided as
  1649. * an array.
  1650. *
  1651. * **Note:** This method is based on the
  1652. * [rest parameter](https://mdn.io/rest_parameters).
  1653. *
  1654. * @static
  1655. * @memberOf _
  1656. * @since 4.0.0
  1657. * @category Function
  1658. * @param {Function} func The function to apply a rest parameter to.
  1659. * @param {number} [start=func.length-1] The start position of the rest parameter.
  1660. * @returns {Function} Returns the new function.
  1661. * @example
  1662. *
  1663. * var say = _.rest(function(what, names) {
  1664. * return what + ' ' + _.initial(names).join(', ') +
  1665. * (_.size(names) > 1 ? ', & ' : '') + _.last(names);
  1666. * });
  1667. *
  1668. * say('hello', 'fred', 'barney', 'pebbles');
  1669. * // => 'hello fred, barney, & pebbles'
  1670. */
  1671. function rest(func, start) {
  1672. if (typeof func != 'function') {
  1673. throw new TypeError(FUNC_ERROR_TEXT);
  1674. }
  1675. start = nativeMax(start === undefined ? (func.length - 1) : toInteger(start), 0);
  1676. return function() {
  1677. var args = arguments,
  1678. index = -1,
  1679. length = nativeMax(args.length - start, 0),
  1680. array = Array(length);
  1681. while (++index < length) {
  1682. array[index] = args[start + index];
  1683. }
  1684. switch (start) {
  1685. case 0: return func.call(this, array);
  1686. case 1: return func.call(this, args[0], array);
  1687. case 2: return func.call(this, args[0], args[1], array);
  1688. }
  1689. var otherArgs = Array(start + 1);
  1690. index = -1;
  1691. while (++index < start) {
  1692. otherArgs[index] = args[index];
  1693. }
  1694. otherArgs[start] = array;
  1695. return apply(func, this, otherArgs);
  1696. };
  1697. }
  1698. /*------------------------------------------------------------------------*/
  1699. /**
  1700. * This method is like `_.clone` except that it recursively clones `value`.
  1701. *
  1702. * @static
  1703. * @memberOf _
  1704. * @since 1.0.0
  1705. * @category Lang
  1706. * @param {*} value The value to recursively clone.
  1707. * @returns {*} Returns the deep cloned value.
  1708. * @see _.clone
  1709. * @example
  1710. *
  1711. * var objects = [{ 'a': 1 }, { 'b': 2 }];
  1712. *
  1713. * var deep = _.cloneDeep(objects);
  1714. * console.log(deep[0] === objects[0]);
  1715. * // => false
  1716. */
  1717. function cloneDeep(value) {
  1718. return baseClone(value, true, true);
  1719. }
  1720. /**
  1721. * Performs a
  1722. * [`SameValueZero`](http://ecma-international.org/ecma-262/6.0/#sec-samevaluezero)
  1723. * comparison between two values to determine if they are equivalent.
  1724. *
  1725. * @static
  1726. * @memberOf _
  1727. * @since 4.0.0
  1728. * @category Lang
  1729. * @param {*} value The value to compare.
  1730. * @param {*} other The other value to compare.
  1731. * @returns {boolean} Returns `true` if the values are equivalent, else `false`.
  1732. * @example
  1733. *
  1734. * var object = { 'user': 'fred' };
  1735. * var other = { 'user': 'fred' };
  1736. *
  1737. * _.eq(object, object);
  1738. * // => true
  1739. *
  1740. * _.eq(object, other);
  1741. * // => false
  1742. *
  1743. * _.eq('a', 'a');
  1744. * // => true
  1745. *
  1746. * _.eq('a', Object('a'));
  1747. * // => false
  1748. *
  1749. * _.eq(NaN, NaN);
  1750. * // => true
  1751. */
  1752. function eq(value, other) {
  1753. return value === other || (value !== value && other !== other);
  1754. }
  1755. /**
  1756. * Checks if `value` is likely an `arguments` object.
  1757. *
  1758. * @static
  1759. * @memberOf _
  1760. * @since 0.1.0
  1761. * @category Lang
  1762. * @param {*} value The value to check.
  1763. * @returns {boolean} Returns `true` if `value` is correctly classified,
  1764. * else `false`.
  1765. * @example
  1766. *
  1767. * _.isArguments(function() { return arguments; }());
  1768. * // => true
  1769. *
  1770. * _.isArguments([1, 2, 3]);
  1771. * // => false
  1772. */
  1773. function isArguments(value) {
  1774. // Safari 8.1 incorrectly makes `arguments.callee` enumerable in strict mode.
  1775. return isArrayLikeObject(value) && hasOwnProperty.call(value, 'callee') &&
  1776. (!propertyIsEnumerable.call(value, 'callee') || objectToString.call(value) == argsTag);
  1777. }
  1778. /**
  1779. * Checks if `value` is classified as an `Array` object.
  1780. *
  1781. * @static
  1782. * @memberOf _
  1783. * @since 0.1.0
  1784. * @type {Function}
  1785. * @category Lang
  1786. * @param {*} value The value to check.
  1787. * @returns {boolean} Returns `true` if `value` is correctly classified,
  1788. * else `false`.
  1789. * @example
  1790. *
  1791. * _.isArray([1, 2, 3]);
  1792. * // => true
  1793. *
  1794. * _.isArray(document.body.children);
  1795. * // => false
  1796. *
  1797. * _.isArray('abc');
  1798. * // => false
  1799. *
  1800. * _.isArray(_.noop);
  1801. * // => false
  1802. */
  1803. var isArray = Array.isArray;
  1804. /**
  1805. * Checks if `value` is array-like. A value is considered array-like if it's
  1806. * not a function and has a `value.length` that's an integer greater than or
  1807. * equal to `0` and less than or equal to `Number.MAX_SAFE_INTEGER`.
  1808. *
  1809. * @static
  1810. * @memberOf _
  1811. * @since 4.0.0
  1812. * @category Lang
  1813. * @param {*} value The value to check.
  1814. * @returns {boolean} Returns `true` if `value` is array-like, else `false`.
  1815. * @example
  1816. *
  1817. * _.isArrayLike([1, 2, 3]);
  1818. * // => true
  1819. *
  1820. * _.isArrayLike(document.body.children);
  1821. * // => true
  1822. *
  1823. * _.isArrayLike('abc');
  1824. * // => true
  1825. *
  1826. * _.isArrayLike(_.noop);
  1827. * // => false
  1828. */
  1829. function isArrayLike(value) {
  1830. return value != null && isLength(getLength(value)) && !isFunction(value);
  1831. }
  1832. /**
  1833. * This method is like `_.isArrayLike` except that it also checks if `value`
  1834. * is an object.
  1835. *
  1836. * @static
  1837. * @memberOf _
  1838. * @since 4.0.0
  1839. * @category Lang
  1840. * @param {*} value The value to check.
  1841. * @returns {boolean} Returns `true` if `value` is an array-like object,
  1842. * else `false`.
  1843. * @example
  1844. *
  1845. * _.isArrayLikeObject([1, 2, 3]);
  1846. * // => true
  1847. *
  1848. * _.isArrayLikeObject(document.body.children);
  1849. * // => true
  1850. *
  1851. * _.isArrayLikeObject('abc');
  1852. * // => false
  1853. *
  1854. * _.isArrayLikeObject(_.noop);
  1855. * // => false
  1856. */
  1857. function isArrayLikeObject(value) {
  1858. return isObjectLike(value) && isArrayLike(value);
  1859. }
  1860. /**
  1861. * Checks if `value` is a buffer.
  1862. *
  1863. * @static
  1864. * @memberOf _
  1865. * @since 4.3.0
  1866. * @category Lang
  1867. * @param {*} value The value to check.
  1868. * @returns {boolean} Returns `true` if `value` is a buffer, else `false`.
  1869. * @example
  1870. *
  1871. * _.isBuffer(new Buffer(2));
  1872. * // => true
  1873. *
  1874. * _.isBuffer(new Uint8Array(2));
  1875. * // => false
  1876. */
  1877. var isBuffer = !Buffer ? constant(false) : function(value) {
  1878. return value instanceof Buffer;
  1879. };
  1880. /**
  1881. * Checks if `value` is classified as a `Function` object.
  1882. *
  1883. * @static
  1884. * @memberOf _
  1885. * @since 0.1.0
  1886. * @category Lang
  1887. * @param {*} value The value to check.
  1888. * @returns {boolean} Returns `true` if `value` is correctly classified,
  1889. * else `false`.
  1890. * @example
  1891. *
  1892. * _.isFunction(_);
  1893. * // => true
  1894. *
  1895. * _.isFunction(/abc/);
  1896. * // => false
  1897. */
  1898. function isFunction(value) {
  1899. // The use of `Object#toString` avoids issues with the `typeof` operator
  1900. // in Safari 8 which returns 'object' for typed array and weak map constructors,
  1901. // and PhantomJS 1.9 which returns 'function' for `NodeList` instances.
  1902. var tag = isObject(value) ? objectToString.call(value) : '';
  1903. return tag == funcTag || tag == genTag;
  1904. }
  1905. /**
  1906. * Checks if `value` is a valid array-like length.
  1907. *
  1908. * **Note:** This function is loosely based on
  1909. * [`ToLength`](http://ecma-international.org/ecma-262/6.0/#sec-tolength).
  1910. *
  1911. * @static
  1912. * @memberOf _
  1913. * @since 4.0.0
  1914. * @category Lang
  1915. * @param {*} value The value to check.
  1916. * @returns {boolean} Returns `true` if `value` is a valid length,
  1917. * else `false`.
  1918. * @example
  1919. *
  1920. * _.isLength(3);
  1921. * // => true
  1922. *
  1923. * _.isLength(Number.MIN_VALUE);
  1924. * // => false
  1925. *
  1926. * _.isLength(Infinity);
  1927. * // => false
  1928. *
  1929. * _.isLength('3');
  1930. * // => false
  1931. */
  1932. function isLength(value) {
  1933. return typeof value == 'number' &&
  1934. value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER;
  1935. }
  1936. /**
  1937. * Checks if `value` is the
  1938. * [language type](http://www.ecma-international.org/ecma-262/6.0/#sec-ecmascript-language-types)
  1939. * of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)
  1940. *
  1941. * @static
  1942. * @memberOf _
  1943. * @since 0.1.0
  1944. * @category Lang
  1945. * @param {*} value The value to check.
  1946. * @returns {boolean} Returns `true` if `value` is an object, else `false`.
  1947. * @example
  1948. *
  1949. * _.isObject({});
  1950. * // => true
  1951. *
  1952. * _.isObject([1, 2, 3]);
  1953. * // => true
  1954. *
  1955. * _.isObject(_.noop);
  1956. * // => true
  1957. *
  1958. * _.isObject(null);
  1959. * // => false
  1960. */
  1961. function isObject(value) {
  1962. var type = typeof value;
  1963. return !!value && (type == 'object' || type == 'function');
  1964. }
  1965. /**
  1966. * Checks if `value` is object-like. A value is object-like if it's not `null`
  1967. * and has a `typeof` result of "object".
  1968. *
  1969. * @static
  1970. * @memberOf _
  1971. * @since 4.0.0
  1972. * @category Lang
  1973. * @param {*} value The value to check.
  1974. * @returns {boolean} Returns `true` if `value` is object-like, else `false`.
  1975. * @example
  1976. *
  1977. * _.isObjectLike({});
  1978. * // => true
  1979. *
  1980. * _.isObjectLike([1, 2, 3]);
  1981. * // => true
  1982. *
  1983. * _.isObjectLike(_.noop);
  1984. * // => false
  1985. *
  1986. * _.isObjectLike(null);
  1987. * // => false
  1988. */
  1989. function isObjectLike(value) {
  1990. return !!value && typeof value == 'object';
  1991. }
  1992. /**
  1993. * Checks if `value` is a native function.
  1994. *
  1995. * @static
  1996. * @memberOf _
  1997. * @since 3.0.0
  1998. * @category Lang
  1999. * @param {*} value The value to check.
  2000. * @returns {boolean} Returns `true` if `value` is a native function,
  2001. * else `false`.
  2002. * @example
  2003. *
  2004. * _.isNative(Array.prototype.push);
  2005. * // => true
  2006. *
  2007. * _.isNative(_);
  2008. * // => false
  2009. */
  2010. function isNative(value) {
  2011. if (!isObject(value)) {
  2012. return false;
  2013. }
  2014. var pattern = (isFunction(value) || isHostObject(value)) ? reIsNative : reIsHostCtor;
  2015. return pattern.test(toSource(value));
  2016. }
  2017. /**
  2018. * Checks if `value` is a plain object, that is, an object created by the
  2019. * `Object` constructor or one with a `[[Prototype]]` of `null`.
  2020. *
  2021. * @static
  2022. * @memberOf _
  2023. * @since 0.8.0
  2024. * @category Lang
  2025. * @param {*} value The value to check.
  2026. * @returns {boolean} Returns `true` if `value` is a plain object,
  2027. * else `false`.
  2028. * @example
  2029. *
  2030. * function Foo() {
  2031. * this.a = 1;
  2032. * }
  2033. *
  2034. * _.isPlainObject(new Foo);
  2035. * // => false
  2036. *
  2037. * _.isPlainObject([1, 2, 3]);
  2038. * // => false
  2039. *
  2040. * _.isPlainObject({ 'x': 0, 'y': 0 });
  2041. * // => true
  2042. *
  2043. * _.isPlainObject(Object.create(null));
  2044. * // => true
  2045. */
  2046. function isPlainObject(value) {
  2047. if (!isObjectLike(value) ||
  2048. objectToString.call(value) != objectTag || isHostObject(value)) {
  2049. return false;
  2050. }
  2051. var proto = getPrototype(value);
  2052. if (proto === null) {
  2053. return true;
  2054. }
  2055. var Ctor = hasOwnProperty.call(proto, 'constructor') && proto.constructor;
  2056. return (typeof Ctor == 'function' &&
  2057. Ctor instanceof Ctor && funcToString.call(Ctor) == objectCtorString);
  2058. }
  2059. /**
  2060. * Checks if `value` is classified as a `String` primitive or object.
  2061. *
  2062. * @static
  2063. * @since 0.1.0
  2064. * @memberOf _
  2065. * @category Lang
  2066. * @param {*} value The value to check.
  2067. * @returns {boolean} Returns `true` if `value` is correctly classified,
  2068. * else `false`.
  2069. * @example
  2070. *
  2071. * _.isString('abc');
  2072. * // => true
  2073. *
  2074. * _.isString(1);
  2075. * // => false
  2076. */
  2077. function isString(value) {
  2078. return typeof value == 'string' ||
  2079. (!isArray(value) && isObjectLike(value) && objectToString.call(value) == stringTag);
  2080. }
  2081. /**
  2082. * Checks if `value` is classified as a `Symbol` primitive or object.
  2083. *
  2084. * @static
  2085. * @memberOf _
  2086. * @since 4.0.0
  2087. * @category Lang
  2088. * @param {*} value The value to check.
  2089. * @returns {boolean} Returns `true` if `value` is correctly classified,
  2090. * else `false`.
  2091. * @example
  2092. *
  2093. * _.isSymbol(Symbol.iterator);
  2094. * // => true
  2095. *
  2096. * _.isSymbol('abc');
  2097. * // => false
  2098. */
  2099. function isSymbol(value) {
  2100. return typeof value == 'symbol' ||
  2101. (isObjectLike(value) && objectToString.call(value) == symbolTag);
  2102. }
  2103. /**
  2104. * Checks if `value` is classified as a typed array.
  2105. *
  2106. * @static
  2107. * @memberOf _
  2108. * @since 3.0.0
  2109. * @category Lang
  2110. * @param {*} value The value to check.
  2111. * @returns {boolean} Returns `true` if `value` is correctly classified,
  2112. * else `false`.
  2113. * @example
  2114. *
  2115. * _.isTypedArray(new Uint8Array);
  2116. * // => true
  2117. *
  2118. * _.isTypedArray([]);
  2119. * // => false
  2120. */
  2121. function isTypedArray(value) {
  2122. return isObjectLike(value) &&
  2123. isLength(value.length) && !!typedArrayTags[objectToString.call(value)];
  2124. }
  2125. /**
  2126. * Converts `value` to a finite number.
  2127. *
  2128. * @static
  2129. * @memberOf _
  2130. * @since 4.12.0
  2131. * @category Lang
  2132. * @param {*} value The value to convert.
  2133. * @returns {number} Returns the converted number.
  2134. * @example
  2135. *
  2136. * _.toFinite(3.2);
  2137. * // => 3.2
  2138. *
  2139. * _.toFinite(Number.MIN_VALUE);
  2140. * // => 5e-324
  2141. *
  2142. * _.toFinite(Infinity);
  2143. * // => 1.7976931348623157e+308
  2144. *
  2145. * _.toFinite('3.2');
  2146. * // => 3.2
  2147. */
  2148. function toFinite(value) {
  2149. if (!value) {
  2150. return value === 0 ? value : 0;
  2151. }
  2152. value = toNumber(value);
  2153. if (value === INFINITY || value === -INFINITY) {
  2154. var sign = (value < 0 ? -1 : 1);
  2155. return sign * MAX_INTEGER;
  2156. }
  2157. return value === value ? value : 0;
  2158. }
  2159. /**
  2160. * Converts `value` to an integer.
  2161. *
  2162. * **Note:** This function is loosely based on
  2163. * [`ToInteger`](http://www.ecma-international.org/ecma-262/6.0/#sec-tointeger).
  2164. *
  2165. * @static
  2166. * @memberOf _
  2167. * @since 4.0.0
  2168. * @category Lang
  2169. * @param {*} value The value to convert.
  2170. * @returns {number} Returns the converted integer.
  2171. * @example
  2172. *
  2173. * _.toInteger(3.2);
  2174. * // => 3
  2175. *
  2176. * _.toInteger(Number.MIN_VALUE);
  2177. * // => 0
  2178. *
  2179. * _.toInteger(Infinity);
  2180. * // => 1.7976931348623157e+308
  2181. *
  2182. * _.toInteger('3.2');
  2183. * // => 3
  2184. */
  2185. function toInteger(value) {
  2186. var result = toFinite(value),
  2187. remainder = result % 1;
  2188. return result === result ? (remainder ? result - remainder : result) : 0;
  2189. }
  2190. /**
  2191. * Converts `value` to a number.
  2192. *
  2193. * @static
  2194. * @memberOf _
  2195. * @since 4.0.0
  2196. * @category Lang
  2197. * @param {*} value The value to process.
  2198. * @returns {number} Returns the number.
  2199. * @example
  2200. *
  2201. * _.toNumber(3.2);
  2202. * // => 3.2
  2203. *
  2204. * _.toNumber(Number.MIN_VALUE);
  2205. * // => 5e-324
  2206. *
  2207. * _.toNumber(Infinity);
  2208. * // => Infinity
  2209. *
  2210. * _.toNumber('3.2');
  2211. * // => 3.2
  2212. */
  2213. function toNumber(value) {
  2214. if (typeof value == 'number') {
  2215. return value;
  2216. }
  2217. if (isSymbol(value)) {
  2218. return NAN;
  2219. }
  2220. if (isObject(value)) {
  2221. var other = isFunction(value.valueOf) ? value.valueOf() : value;
  2222. value = isObject(other) ? (other + '') : other;
  2223. }
  2224. if (typeof value != 'string') {
  2225. return value === 0 ? value : +value;
  2226. }
  2227. value = value.replace(reTrim, '');
  2228. var isBinary = reIsBinary.test(value);
  2229. return (isBinary || reIsOctal.test(value))
  2230. ? freeParseInt(value.slice(2), isBinary ? 2 : 8)
  2231. : (reIsBadHex.test(value) ? NAN : +value);
  2232. }
  2233. /**
  2234. * Converts `value` to a plain object flattening inherited enumerable string
  2235. * keyed properties of `value` to own properties of the plain object.
  2236. *
  2237. * @static
  2238. * @memberOf _
  2239. * @since 3.0.0
  2240. * @category Lang
  2241. * @param {*} value The value to convert.
  2242. * @returns {Object} Returns the converted plain object.
  2243. * @example
  2244. *
  2245. * function Foo() {
  2246. * this.b = 2;
  2247. * }
  2248. *
  2249. * Foo.prototype.c = 3;
  2250. *
  2251. * _.assign({ 'a': 1 }, new Foo);
  2252. * // => { 'a': 1, 'b': 2 }
  2253. *
  2254. * _.assign({ 'a': 1 }, _.toPlainObject(new Foo));
  2255. * // => { 'a': 1, 'b': 2, 'c': 3 }
  2256. */
  2257. function toPlainObject(value) {
  2258. return copyObject(value, keysIn(value));
  2259. }
  2260. /*------------------------------------------------------------------------*/
  2261. /**
  2262. * Creates an array of the own enumerable property names of `object`.
  2263. *
  2264. * **Note:** Non-object values are coerced to objects. See the
  2265. * [ES spec](http://ecma-international.org/ecma-262/6.0/#sec-object.keys)
  2266. * for more details.
  2267. *
  2268. * @static
  2269. * @since 0.1.0
  2270. * @memberOf _
  2271. * @category Object
  2272. * @param {Object} object The object to query.
  2273. * @returns {Array} Returns the array of property names.
  2274. * @example
  2275. *
  2276. * function Foo() {
  2277. * this.a = 1;
  2278. * this.b = 2;
  2279. * }
  2280. *
  2281. * Foo.prototype.c = 3;
  2282. *
  2283. * _.keys(new Foo);
  2284. * // => ['a', 'b'] (iteration order is not guaranteed)
  2285. *
  2286. * _.keys('hi');
  2287. * // => ['0', '1']
  2288. */
  2289. function keys(object) {
  2290. var isProto = isPrototype(object);
  2291. if (!(isProto || isArrayLike(object))) {
  2292. return baseKeys(object);
  2293. }
  2294. var indexes = indexKeys(object),
  2295. skipIndexes = !!indexes,
  2296. result = indexes || [],
  2297. length = result.length;
  2298. for (var key in object) {
  2299. if (baseHas(object, key) &&
  2300. !(skipIndexes && (key == 'length' || isIndex(key, length))) &&
  2301. !(isProto && key == 'constructor')) {
  2302. result.push(key);
  2303. }
  2304. }
  2305. return result;
  2306. }
  2307. /**
  2308. * Creates an array of the own and inherited enumerable property names of `object`.
  2309. *
  2310. * **Note:** Non-object values are coerced to objects.
  2311. *
  2312. * @static
  2313. * @memberOf _
  2314. * @since 3.0.0
  2315. * @category Object
  2316. * @param {Object} object The object to query.
  2317. * @returns {Array} Returns the array of property names.
  2318. * @example
  2319. *
  2320. * function Foo() {
  2321. * this.a = 1;
  2322. * this.b = 2;
  2323. * }
  2324. *
  2325. * Foo.prototype.c = 3;
  2326. *
  2327. * _.keysIn(new Foo);
  2328. * // => ['a', 'b', 'c'] (iteration order is not guaranteed)
  2329. */
  2330. function keysIn(object) {
  2331. var index = -1,
  2332. isProto = isPrototype(object),
  2333. props = baseKeysIn(object),
  2334. propsLength = props.length,
  2335. indexes = indexKeys(object),
  2336. skipIndexes = !!indexes,
  2337. result = indexes || [],
  2338. length = result.length;
  2339. while (++index < propsLength) {
  2340. var key = props[index];
  2341. if (!(skipIndexes && (key == 'length' || isIndex(key, length))) &&
  2342. !(key == 'constructor' && (isProto || !hasOwnProperty.call(object, key)))) {
  2343. result.push(key);
  2344. }
  2345. }
  2346. return result;
  2347. }
  2348. /**
  2349. * This method is like `_.assign` except that it recursively merges own and
  2350. * inherited enumerable string keyed properties of source objects into the
  2351. * destination object. Source properties that resolve to `undefined` are
  2352. * skipped if a destination value exists. Array and plain object properties
  2353. * are merged recursively. Other objects and value types are overridden by
  2354. * assignment. Source objects are applied from left to right. Subsequent
  2355. * sources overwrite property assignments of previous sources.
  2356. *
  2357. * **Note:** This method mutates `object`.
  2358. *
  2359. * @static
  2360. * @memberOf _
  2361. * @since 0.5.0
  2362. * @category Object
  2363. * @param {Object} object The destination object.
  2364. * @param {...Object} [sources] The source objects.
  2365. * @returns {Object} Returns `object`.
  2366. * @example
  2367. *
  2368. * var users = {
  2369. * 'data': [{ 'user': 'barney' }, { 'user': 'fred' }]
  2370. * };
  2371. *
  2372. * var ages = {
  2373. * 'data': [{ 'age': 36 }, { 'age': 40 }]
  2374. * };
  2375. *
  2376. * _.merge(users, ages);
  2377. * // => { 'data': [{ 'user': 'barney', 'age': 36 }, { 'user': 'fred', 'age': 40 }] }
  2378. */
  2379. var merge = createAssigner(function(object, source, srcIndex) {
  2380. baseMerge(object, source, srcIndex);
  2381. });
  2382. /*------------------------------------------------------------------------*/
  2383. /**
  2384. * Creates a function that returns `value`.
  2385. *
  2386. * @static
  2387. * @memberOf _
  2388. * @since 2.4.0
  2389. * @category Util
  2390. * @param {*} value The value to return from the new function.
  2391. * @returns {Function} Returns the new constant function.
  2392. * @example
  2393. *
  2394. * var object = { 'user': 'fred' };
  2395. * var getter = _.constant(object);
  2396. *
  2397. * getter() === object;
  2398. * // => true
  2399. */
  2400. function constant(value) {
  2401. return function() {
  2402. return value;
  2403. };
  2404. }
  2405. /*------------------------------------------------------------------------*/
  2406. // Add methods that return wrapped values in chain sequences.
  2407. lodash.constant = constant;
  2408. lodash.keys = keys;
  2409. lodash.keysIn = keysIn;
  2410. lodash.merge = merge;
  2411. lodash.rest = rest;
  2412. lodash.toPlainObject = toPlainObject;
  2413. /*------------------------------------------------------------------------*/
  2414. // Add methods that return unwrapped values in chain sequences.
  2415. lodash.cloneDeep = cloneDeep;
  2416. lodash.eq = eq;
  2417. lodash.isArguments = isArguments;
  2418. lodash.isArray = isArray;
  2419. lodash.isArrayLike = isArrayLike;
  2420. lodash.isArrayLikeObject = isArrayLikeObject;
  2421. lodash.isBuffer = isBuffer;
  2422. lodash.isFunction = isFunction;
  2423. lodash.isLength = isLength;
  2424. lodash.isNative = isNative;
  2425. lodash.isObject = isObject;
  2426. lodash.isObjectLike = isObjectLike;
  2427. lodash.isPlainObject = isPlainObject;
  2428. lodash.isString = isString;
  2429. lodash.isSymbol = isSymbol;
  2430. lodash.isTypedArray = isTypedArray;
  2431. lodash.toFinite = toFinite;
  2432. lodash.toInteger = toInteger;
  2433. lodash.toNumber = toNumber;
  2434. /*------------------------------------------------------------------------*/
  2435. /**
  2436. * The semantic version number.
  2437. *
  2438. * @static
  2439. * @memberOf _
  2440. * @type {string}
  2441. */
  2442. lodash.VERSION = VERSION;
  2443. /*--------------------------------------------------------------------------*/
  2444. // Expose Lodash on the free variable `window` or `self` when available so it's
  2445. // globally accessible, even when bundled with Browserify, Webpack, etc. This
  2446. // also prevents errors in cases where Lodash is loaded by a script tag in the
  2447. // presence of an AMD loader. See http://requirejs.org/docs/errors.html#mismatch
  2448. // for more details. Use `_.noConflict` to remove Lodash from the global object.
  2449. (freeWindow || freeSelf || {})._ = lodash;
  2450. if (freeExports && freeModule) {
  2451. // Export for Node.js.
  2452. if (moduleExports) {
  2453. (freeModule.exports = lodash)._ = lodash;
  2454. }
  2455. // Export for CommonJS support.
  2456. freeExports._ = lodash;
  2457. }
  2458. }.call(this));