UI for Zipcoin Blue

index.js 44KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749
  1. /**
  2. * lodash (Custom Build) <https://lodash.com/>
  3. * Build: `lodash modularize exports="npm" -o ./`
  4. * Copyright jQuery Foundation and other contributors <https://jquery.org/>
  5. * Released under MIT license <https://lodash.com/license>
  6. * Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
  7. * Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
  8. */
  9. /** Used as the size to enable large array optimizations. */
  10. var LARGE_ARRAY_SIZE = 200;
  11. /** Used to stand-in for `undefined` hash values. */
  12. var HASH_UNDEFINED = '__lodash_hash_undefined__';
  13. /** Used as references for various `Number` constants. */
  14. var MAX_SAFE_INTEGER = 9007199254740991;
  15. /** `Object#toString` result references. */
  16. var argsTag = '[object Arguments]',
  17. arrayTag = '[object Array]',
  18. boolTag = '[object Boolean]',
  19. dateTag = '[object Date]',
  20. errorTag = '[object Error]',
  21. funcTag = '[object Function]',
  22. genTag = '[object GeneratorFunction]',
  23. mapTag = '[object Map]',
  24. numberTag = '[object Number]',
  25. objectTag = '[object Object]',
  26. promiseTag = '[object Promise]',
  27. regexpTag = '[object RegExp]',
  28. setTag = '[object Set]',
  29. stringTag = '[object String]',
  30. symbolTag = '[object Symbol]',
  31. weakMapTag = '[object WeakMap]';
  32. var arrayBufferTag = '[object ArrayBuffer]',
  33. dataViewTag = '[object DataView]',
  34. float32Tag = '[object Float32Array]',
  35. float64Tag = '[object Float64Array]',
  36. int8Tag = '[object Int8Array]',
  37. int16Tag = '[object Int16Array]',
  38. int32Tag = '[object Int32Array]',
  39. uint8Tag = '[object Uint8Array]',
  40. uint8ClampedTag = '[object Uint8ClampedArray]',
  41. uint16Tag = '[object Uint16Array]',
  42. uint32Tag = '[object Uint32Array]';
  43. /**
  44. * Used to match `RegExp`
  45. * [syntax characters](http://ecma-international.org/ecma-262/7.0/#sec-patterns).
  46. */
  47. var reRegExpChar = /[\\^$.*+?()[\]{}|]/g;
  48. /** Used to match `RegExp` flags from their coerced string values. */
  49. var reFlags = /\w*$/;
  50. /** Used to detect host constructors (Safari). */
  51. var reIsHostCtor = /^\[object .+?Constructor\]$/;
  52. /** Used to detect unsigned integer values. */
  53. var reIsUint = /^(?:0|[1-9]\d*)$/;
  54. /** Used to identify `toStringTag` values supported by `_.clone`. */
  55. var cloneableTags = {};
  56. cloneableTags[argsTag] = cloneableTags[arrayTag] =
  57. cloneableTags[arrayBufferTag] = cloneableTags[dataViewTag] =
  58. cloneableTags[boolTag] = cloneableTags[dateTag] =
  59. cloneableTags[float32Tag] = cloneableTags[float64Tag] =
  60. cloneableTags[int8Tag] = cloneableTags[int16Tag] =
  61. cloneableTags[int32Tag] = cloneableTags[mapTag] =
  62. cloneableTags[numberTag] = cloneableTags[objectTag] =
  63. cloneableTags[regexpTag] = cloneableTags[setTag] =
  64. cloneableTags[stringTag] = cloneableTags[symbolTag] =
  65. cloneableTags[uint8Tag] = cloneableTags[uint8ClampedTag] =
  66. cloneableTags[uint16Tag] = cloneableTags[uint32Tag] = true;
  67. cloneableTags[errorTag] = cloneableTags[funcTag] =
  68. cloneableTags[weakMapTag] = false;
  69. /** Detect free variable `global` from Node.js. */
  70. var freeGlobal = typeof global == 'object' && global && global.Object === Object && global;
  71. /** Detect free variable `self`. */
  72. var freeSelf = typeof self == 'object' && self && self.Object === Object && self;
  73. /** Used as a reference to the global object. */
  74. var root = freeGlobal || freeSelf || Function('return this')();
  75. /** Detect free variable `exports`. */
  76. var freeExports = typeof exports == 'object' && exports && !exports.nodeType && exports;
  77. /** Detect free variable `module`. */
  78. var freeModule = freeExports && typeof module == 'object' && module && !module.nodeType && module;
  79. /** Detect the popular CommonJS extension `module.exports`. */
  80. var moduleExports = freeModule && freeModule.exports === freeExports;
  81. /**
  82. * Adds the key-value `pair` to `map`.
  83. *
  84. * @private
  85. * @param {Object} map The map to modify.
  86. * @param {Array} pair The key-value pair to add.
  87. * @returns {Object} Returns `map`.
  88. */
  89. function addMapEntry(map, pair) {
  90. // Don't return `map.set` because it's not chainable in IE 11.
  91. map.set(pair[0], pair[1]);
  92. return map;
  93. }
  94. /**
  95. * Adds `value` to `set`.
  96. *
  97. * @private
  98. * @param {Object} set The set to modify.
  99. * @param {*} value The value to add.
  100. * @returns {Object} Returns `set`.
  101. */
  102. function addSetEntry(set, value) {
  103. // Don't return `set.add` because it's not chainable in IE 11.
  104. set.add(value);
  105. return set;
  106. }
  107. /**
  108. * A specialized version of `_.forEach` for arrays without support for
  109. * iteratee shorthands.
  110. *
  111. * @private
  112. * @param {Array} [array] The array to iterate over.
  113. * @param {Function} iteratee The function invoked per iteration.
  114. * @returns {Array} Returns `array`.
  115. */
  116. function arrayEach(array, iteratee) {
  117. var index = -1,
  118. length = array ? array.length : 0;
  119. while (++index < length) {
  120. if (iteratee(array[index], index, array) === false) {
  121. break;
  122. }
  123. }
  124. return array;
  125. }
  126. /**
  127. * Appends the elements of `values` to `array`.
  128. *
  129. * @private
  130. * @param {Array} array The array to modify.
  131. * @param {Array} values The values to append.
  132. * @returns {Array} Returns `array`.
  133. */
  134. function arrayPush(array, values) {
  135. var index = -1,
  136. length = values.length,
  137. offset = array.length;
  138. while (++index < length) {
  139. array[offset + index] = values[index];
  140. }
  141. return array;
  142. }
  143. /**
  144. * A specialized version of `_.reduce` for arrays without support for
  145. * iteratee shorthands.
  146. *
  147. * @private
  148. * @param {Array} [array] The array to iterate over.
  149. * @param {Function} iteratee The function invoked per iteration.
  150. * @param {*} [accumulator] The initial value.
  151. * @param {boolean} [initAccum] Specify using the first element of `array` as
  152. * the initial value.
  153. * @returns {*} Returns the accumulated value.
  154. */
  155. function arrayReduce(array, iteratee, accumulator, initAccum) {
  156. var index = -1,
  157. length = array ? array.length : 0;
  158. if (initAccum && length) {
  159. accumulator = array[++index];
  160. }
  161. while (++index < length) {
  162. accumulator = iteratee(accumulator, array[index], index, array);
  163. }
  164. return accumulator;
  165. }
  166. /**
  167. * The base implementation of `_.times` without support for iteratee shorthands
  168. * or max array length checks.
  169. *
  170. * @private
  171. * @param {number} n The number of times to invoke `iteratee`.
  172. * @param {Function} iteratee The function invoked per iteration.
  173. * @returns {Array} Returns the array of results.
  174. */
  175. function baseTimes(n, iteratee) {
  176. var index = -1,
  177. result = Array(n);
  178. while (++index < n) {
  179. result[index] = iteratee(index);
  180. }
  181. return result;
  182. }
  183. /**
  184. * Gets the value at `key` of `object`.
  185. *
  186. * @private
  187. * @param {Object} [object] The object to query.
  188. * @param {string} key The key of the property to get.
  189. * @returns {*} Returns the property value.
  190. */
  191. function getValue(object, key) {
  192. return object == null ? undefined : object[key];
  193. }
  194. /**
  195. * Checks if `value` is a host object in IE < 9.
  196. *
  197. * @private
  198. * @param {*} value The value to check.
  199. * @returns {boolean} Returns `true` if `value` is a host object, else `false`.
  200. */
  201. function isHostObject(value) {
  202. // Many host objects are `Object` objects that can coerce to strings
  203. // despite having improperly defined `toString` methods.
  204. var result = false;
  205. if (value != null && typeof value.toString != 'function') {
  206. try {
  207. result = !!(value + '');
  208. } catch (e) {}
  209. }
  210. return result;
  211. }
  212. /**
  213. * Converts `map` to its key-value pairs.
  214. *
  215. * @private
  216. * @param {Object} map The map to convert.
  217. * @returns {Array} Returns the key-value pairs.
  218. */
  219. function mapToArray(map) {
  220. var index = -1,
  221. result = Array(map.size);
  222. map.forEach(function(value, key) {
  223. result[++index] = [key, value];
  224. });
  225. return result;
  226. }
  227. /**
  228. * Creates a unary function that invokes `func` with its argument transformed.
  229. *
  230. * @private
  231. * @param {Function} func The function to wrap.
  232. * @param {Function} transform The argument transform.
  233. * @returns {Function} Returns the new function.
  234. */
  235. function overArg(func, transform) {
  236. return function(arg) {
  237. return func(transform(arg));
  238. };
  239. }
  240. /**
  241. * Converts `set` to an array of its values.
  242. *
  243. * @private
  244. * @param {Object} set The set to convert.
  245. * @returns {Array} Returns the values.
  246. */
  247. function setToArray(set) {
  248. var index = -1,
  249. result = Array(set.size);
  250. set.forEach(function(value) {
  251. result[++index] = value;
  252. });
  253. return result;
  254. }
  255. /** Used for built-in method references. */
  256. var arrayProto = Array.prototype,
  257. funcProto = Function.prototype,
  258. objectProto = Object.prototype;
  259. /** Used to detect overreaching core-js shims. */
  260. var coreJsData = root['__core-js_shared__'];
  261. /** Used to detect methods masquerading as native. */
  262. var maskSrcKey = (function() {
  263. var uid = /[^.]+$/.exec(coreJsData && coreJsData.keys && coreJsData.keys.IE_PROTO || '');
  264. return uid ? ('Symbol(src)_1.' + uid) : '';
  265. }());
  266. /** Used to resolve the decompiled source of functions. */
  267. var funcToString = funcProto.toString;
  268. /** Used to check objects for own properties. */
  269. var hasOwnProperty = objectProto.hasOwnProperty;
  270. /**
  271. * Used to resolve the
  272. * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
  273. * of values.
  274. */
  275. var objectToString = objectProto.toString;
  276. /** Used to detect if a method is native. */
  277. var reIsNative = RegExp('^' +
  278. funcToString.call(hasOwnProperty).replace(reRegExpChar, '\\$&')
  279. .replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, '$1.*?') + '$'
  280. );
  281. /** Built-in value references. */
  282. var Buffer = moduleExports ? root.Buffer : undefined,
  283. Symbol = root.Symbol,
  284. Uint8Array = root.Uint8Array,
  285. getPrototype = overArg(Object.getPrototypeOf, Object),
  286. objectCreate = Object.create,
  287. propertyIsEnumerable = objectProto.propertyIsEnumerable,
  288. splice = arrayProto.splice;
  289. /* Built-in method references for those with the same name as other `lodash` methods. */
  290. var nativeGetSymbols = Object.getOwnPropertySymbols,
  291. nativeIsBuffer = Buffer ? Buffer.isBuffer : undefined,
  292. nativeKeys = overArg(Object.keys, Object);
  293. /* Built-in method references that are verified to be native. */
  294. var DataView = getNative(root, 'DataView'),
  295. Map = getNative(root, 'Map'),
  296. Promise = getNative(root, 'Promise'),
  297. Set = getNative(root, 'Set'),
  298. WeakMap = getNative(root, 'WeakMap'),
  299. nativeCreate = getNative(Object, 'create');
  300. /** Used to detect maps, sets, and weakmaps. */
  301. var dataViewCtorString = toSource(DataView),
  302. mapCtorString = toSource(Map),
  303. promiseCtorString = toSource(Promise),
  304. setCtorString = toSource(Set),
  305. weakMapCtorString = toSource(WeakMap);
  306. /** Used to convert symbols to primitives and strings. */
  307. var symbolProto = Symbol ? Symbol.prototype : undefined,
  308. symbolValueOf = symbolProto ? symbolProto.valueOf : undefined;
  309. /**
  310. * Creates a hash object.
  311. *
  312. * @private
  313. * @constructor
  314. * @param {Array} [entries] The key-value pairs to cache.
  315. */
  316. function Hash(entries) {
  317. var index = -1,
  318. length = entries ? entries.length : 0;
  319. this.clear();
  320. while (++index < length) {
  321. var entry = entries[index];
  322. this.set(entry[0], entry[1]);
  323. }
  324. }
  325. /**
  326. * Removes all key-value entries from the hash.
  327. *
  328. * @private
  329. * @name clear
  330. * @memberOf Hash
  331. */
  332. function hashClear() {
  333. this.__data__ = nativeCreate ? nativeCreate(null) : {};
  334. }
  335. /**
  336. * Removes `key` and its value from the hash.
  337. *
  338. * @private
  339. * @name delete
  340. * @memberOf Hash
  341. * @param {Object} hash The hash to modify.
  342. * @param {string} key The key of the value to remove.
  343. * @returns {boolean} Returns `true` if the entry was removed, else `false`.
  344. */
  345. function hashDelete(key) {
  346. return this.has(key) && delete this.__data__[key];
  347. }
  348. /**
  349. * Gets the hash value for `key`.
  350. *
  351. * @private
  352. * @name get
  353. * @memberOf Hash
  354. * @param {string} key The key of the value to get.
  355. * @returns {*} Returns the entry value.
  356. */
  357. function hashGet(key) {
  358. var data = this.__data__;
  359. if (nativeCreate) {
  360. var result = data[key];
  361. return result === HASH_UNDEFINED ? undefined : result;
  362. }
  363. return hasOwnProperty.call(data, key) ? data[key] : undefined;
  364. }
  365. /**
  366. * Checks if a hash value for `key` exists.
  367. *
  368. * @private
  369. * @name has
  370. * @memberOf Hash
  371. * @param {string} key The key of the entry to check.
  372. * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
  373. */
  374. function hashHas(key) {
  375. var data = this.__data__;
  376. return nativeCreate ? data[key] !== undefined : hasOwnProperty.call(data, key);
  377. }
  378. /**
  379. * Sets the hash `key` to `value`.
  380. *
  381. * @private
  382. * @name set
  383. * @memberOf Hash
  384. * @param {string} key The key of the value to set.
  385. * @param {*} value The value to set.
  386. * @returns {Object} Returns the hash instance.
  387. */
  388. function hashSet(key, value) {
  389. var data = this.__data__;
  390. data[key] = (nativeCreate && value === undefined) ? HASH_UNDEFINED : value;
  391. return this;
  392. }
  393. // Add methods to `Hash`.
  394. Hash.prototype.clear = hashClear;
  395. Hash.prototype['delete'] = hashDelete;
  396. Hash.prototype.get = hashGet;
  397. Hash.prototype.has = hashHas;
  398. Hash.prototype.set = hashSet;
  399. /**
  400. * Creates an list cache object.
  401. *
  402. * @private
  403. * @constructor
  404. * @param {Array} [entries] The key-value pairs to cache.
  405. */
  406. function ListCache(entries) {
  407. var index = -1,
  408. length = entries ? entries.length : 0;
  409. this.clear();
  410. while (++index < length) {
  411. var entry = entries[index];
  412. this.set(entry[0], entry[1]);
  413. }
  414. }
  415. /**
  416. * Removes all key-value entries from the list cache.
  417. *
  418. * @private
  419. * @name clear
  420. * @memberOf ListCache
  421. */
  422. function listCacheClear() {
  423. this.__data__ = [];
  424. }
  425. /**
  426. * Removes `key` and its value from the list cache.
  427. *
  428. * @private
  429. * @name delete
  430. * @memberOf ListCache
  431. * @param {string} key The key of the value to remove.
  432. * @returns {boolean} Returns `true` if the entry was removed, else `false`.
  433. */
  434. function listCacheDelete(key) {
  435. var data = this.__data__,
  436. index = assocIndexOf(data, key);
  437. if (index < 0) {
  438. return false;
  439. }
  440. var lastIndex = data.length - 1;
  441. if (index == lastIndex) {
  442. data.pop();
  443. } else {
  444. splice.call(data, index, 1);
  445. }
  446. return true;
  447. }
  448. /**
  449. * Gets the list cache value for `key`.
  450. *
  451. * @private
  452. * @name get
  453. * @memberOf ListCache
  454. * @param {string} key The key of the value to get.
  455. * @returns {*} Returns the entry value.
  456. */
  457. function listCacheGet(key) {
  458. var data = this.__data__,
  459. index = assocIndexOf(data, key);
  460. return index < 0 ? undefined : data[index][1];
  461. }
  462. /**
  463. * Checks if a list cache value for `key` exists.
  464. *
  465. * @private
  466. * @name has
  467. * @memberOf ListCache
  468. * @param {string} key The key of the entry to check.
  469. * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
  470. */
  471. function listCacheHas(key) {
  472. return assocIndexOf(this.__data__, key) > -1;
  473. }
  474. /**
  475. * Sets the list cache `key` to `value`.
  476. *
  477. * @private
  478. * @name set
  479. * @memberOf ListCache
  480. * @param {string} key The key of the value to set.
  481. * @param {*} value The value to set.
  482. * @returns {Object} Returns the list cache instance.
  483. */
  484. function listCacheSet(key, value) {
  485. var data = this.__data__,
  486. index = assocIndexOf(data, key);
  487. if (index < 0) {
  488. data.push([key, value]);
  489. } else {
  490. data[index][1] = value;
  491. }
  492. return this;
  493. }
  494. // Add methods to `ListCache`.
  495. ListCache.prototype.clear = listCacheClear;
  496. ListCache.prototype['delete'] = listCacheDelete;
  497. ListCache.prototype.get = listCacheGet;
  498. ListCache.prototype.has = listCacheHas;
  499. ListCache.prototype.set = listCacheSet;
  500. /**
  501. * Creates a map cache object to store key-value pairs.
  502. *
  503. * @private
  504. * @constructor
  505. * @param {Array} [entries] The key-value pairs to cache.
  506. */
  507. function MapCache(entries) {
  508. var index = -1,
  509. length = entries ? entries.length : 0;
  510. this.clear();
  511. while (++index < length) {
  512. var entry = entries[index];
  513. this.set(entry[0], entry[1]);
  514. }
  515. }
  516. /**
  517. * Removes all key-value entries from the map.
  518. *
  519. * @private
  520. * @name clear
  521. * @memberOf MapCache
  522. */
  523. function mapCacheClear() {
  524. this.__data__ = {
  525. 'hash': new Hash,
  526. 'map': new (Map || ListCache),
  527. 'string': new Hash
  528. };
  529. }
  530. /**
  531. * Removes `key` and its value from the map.
  532. *
  533. * @private
  534. * @name delete
  535. * @memberOf MapCache
  536. * @param {string} key The key of the value to remove.
  537. * @returns {boolean} Returns `true` if the entry was removed, else `false`.
  538. */
  539. function mapCacheDelete(key) {
  540. return getMapData(this, key)['delete'](key);
  541. }
  542. /**
  543. * Gets the map value for `key`.
  544. *
  545. * @private
  546. * @name get
  547. * @memberOf MapCache
  548. * @param {string} key The key of the value to get.
  549. * @returns {*} Returns the entry value.
  550. */
  551. function mapCacheGet(key) {
  552. return getMapData(this, key).get(key);
  553. }
  554. /**
  555. * Checks if a map value for `key` exists.
  556. *
  557. * @private
  558. * @name has
  559. * @memberOf MapCache
  560. * @param {string} key The key of the entry to check.
  561. * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
  562. */
  563. function mapCacheHas(key) {
  564. return getMapData(this, key).has(key);
  565. }
  566. /**
  567. * Sets the map `key` to `value`.
  568. *
  569. * @private
  570. * @name set
  571. * @memberOf MapCache
  572. * @param {string} key The key of the value to set.
  573. * @param {*} value The value to set.
  574. * @returns {Object} Returns the map cache instance.
  575. */
  576. function mapCacheSet(key, value) {
  577. getMapData(this, key).set(key, value);
  578. return this;
  579. }
  580. // Add methods to `MapCache`.
  581. MapCache.prototype.clear = mapCacheClear;
  582. MapCache.prototype['delete'] = mapCacheDelete;
  583. MapCache.prototype.get = mapCacheGet;
  584. MapCache.prototype.has = mapCacheHas;
  585. MapCache.prototype.set = mapCacheSet;
  586. /**
  587. * Creates a stack cache object to store key-value pairs.
  588. *
  589. * @private
  590. * @constructor
  591. * @param {Array} [entries] The key-value pairs to cache.
  592. */
  593. function Stack(entries) {
  594. this.__data__ = new ListCache(entries);
  595. }
  596. /**
  597. * Removes all key-value entries from the stack.
  598. *
  599. * @private
  600. * @name clear
  601. * @memberOf Stack
  602. */
  603. function stackClear() {
  604. this.__data__ = new ListCache;
  605. }
  606. /**
  607. * Removes `key` and its value from the stack.
  608. *
  609. * @private
  610. * @name delete
  611. * @memberOf Stack
  612. * @param {string} key The key of the value to remove.
  613. * @returns {boolean} Returns `true` if the entry was removed, else `false`.
  614. */
  615. function stackDelete(key) {
  616. return this.__data__['delete'](key);
  617. }
  618. /**
  619. * Gets the stack value for `key`.
  620. *
  621. * @private
  622. * @name get
  623. * @memberOf Stack
  624. * @param {string} key The key of the value to get.
  625. * @returns {*} Returns the entry value.
  626. */
  627. function stackGet(key) {
  628. return this.__data__.get(key);
  629. }
  630. /**
  631. * Checks if a stack value for `key` exists.
  632. *
  633. * @private
  634. * @name has
  635. * @memberOf Stack
  636. * @param {string} key The key of the entry to check.
  637. * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
  638. */
  639. function stackHas(key) {
  640. return this.__data__.has(key);
  641. }
  642. /**
  643. * Sets the stack `key` to `value`.
  644. *
  645. * @private
  646. * @name set
  647. * @memberOf Stack
  648. * @param {string} key The key of the value to set.
  649. * @param {*} value The value to set.
  650. * @returns {Object} Returns the stack cache instance.
  651. */
  652. function stackSet(key, value) {
  653. var cache = this.__data__;
  654. if (cache instanceof ListCache) {
  655. var pairs = cache.__data__;
  656. if (!Map || (pairs.length < LARGE_ARRAY_SIZE - 1)) {
  657. pairs.push([key, value]);
  658. return this;
  659. }
  660. cache = this.__data__ = new MapCache(pairs);
  661. }
  662. cache.set(key, value);
  663. return this;
  664. }
  665. // Add methods to `Stack`.
  666. Stack.prototype.clear = stackClear;
  667. Stack.prototype['delete'] = stackDelete;
  668. Stack.prototype.get = stackGet;
  669. Stack.prototype.has = stackHas;
  670. Stack.prototype.set = stackSet;
  671. /**
  672. * Creates an array of the enumerable property names of the array-like `value`.
  673. *
  674. * @private
  675. * @param {*} value The value to query.
  676. * @param {boolean} inherited Specify returning inherited property names.
  677. * @returns {Array} Returns the array of property names.
  678. */
  679. function arrayLikeKeys(value, inherited) {
  680. // Safari 8.1 makes `arguments.callee` enumerable in strict mode.
  681. // Safari 9 makes `arguments.length` enumerable in strict mode.
  682. var result = (isArray(value) || isArguments(value))
  683. ? baseTimes(value.length, String)
  684. : [];
  685. var length = result.length,
  686. skipIndexes = !!length;
  687. for (var key in value) {
  688. if ((inherited || hasOwnProperty.call(value, key)) &&
  689. !(skipIndexes && (key == 'length' || isIndex(key, length)))) {
  690. result.push(key);
  691. }
  692. }
  693. return result;
  694. }
  695. /**
  696. * Assigns `value` to `key` of `object` if the existing value is not equivalent
  697. * using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
  698. * for equality comparisons.
  699. *
  700. * @private
  701. * @param {Object} object The object to modify.
  702. * @param {string} key The key of the property to assign.
  703. * @param {*} value The value to assign.
  704. */
  705. function assignValue(object, key, value) {
  706. var objValue = object[key];
  707. if (!(hasOwnProperty.call(object, key) && eq(objValue, value)) ||
  708. (value === undefined && !(key in object))) {
  709. object[key] = value;
  710. }
  711. }
  712. /**
  713. * Gets the index at which the `key` is found in `array` of key-value pairs.
  714. *
  715. * @private
  716. * @param {Array} array The array to inspect.
  717. * @param {*} key The key to search for.
  718. * @returns {number} Returns the index of the matched value, else `-1`.
  719. */
  720. function assocIndexOf(array, key) {
  721. var length = array.length;
  722. while (length--) {
  723. if (eq(array[length][0], key)) {
  724. return length;
  725. }
  726. }
  727. return -1;
  728. }
  729. /**
  730. * The base implementation of `_.assign` without support for multiple sources
  731. * or `customizer` functions.
  732. *
  733. * @private
  734. * @param {Object} object The destination object.
  735. * @param {Object} source The source object.
  736. * @returns {Object} Returns `object`.
  737. */
  738. function baseAssign(object, source) {
  739. return object && copyObject(source, keys(source), object);
  740. }
  741. /**
  742. * The base implementation of `_.clone` and `_.cloneDeep` which tracks
  743. * traversed objects.
  744. *
  745. * @private
  746. * @param {*} value The value to clone.
  747. * @param {boolean} [isDeep] Specify a deep clone.
  748. * @param {boolean} [isFull] Specify a clone including symbols.
  749. * @param {Function} [customizer] The function to customize cloning.
  750. * @param {string} [key] The key of `value`.
  751. * @param {Object} [object] The parent object of `value`.
  752. * @param {Object} [stack] Tracks traversed objects and their clone counterparts.
  753. * @returns {*} Returns the cloned value.
  754. */
  755. function baseClone(value, isDeep, isFull, customizer, key, object, stack) {
  756. var result;
  757. if (customizer) {
  758. result = object ? customizer(value, key, object, stack) : customizer(value);
  759. }
  760. if (result !== undefined) {
  761. return result;
  762. }
  763. if (!isObject(value)) {
  764. return value;
  765. }
  766. var isArr = isArray(value);
  767. if (isArr) {
  768. result = initCloneArray(value);
  769. if (!isDeep) {
  770. return copyArray(value, result);
  771. }
  772. } else {
  773. var tag = getTag(value),
  774. isFunc = tag == funcTag || tag == genTag;
  775. if (isBuffer(value)) {
  776. return cloneBuffer(value, isDeep);
  777. }
  778. if (tag == objectTag || tag == argsTag || (isFunc && !object)) {
  779. if (isHostObject(value)) {
  780. return object ? value : {};
  781. }
  782. result = initCloneObject(isFunc ? {} : value);
  783. if (!isDeep) {
  784. return copySymbols(value, baseAssign(result, value));
  785. }
  786. } else {
  787. if (!cloneableTags[tag]) {
  788. return object ? value : {};
  789. }
  790. result = initCloneByTag(value, tag, baseClone, isDeep);
  791. }
  792. }
  793. // Check for circular references and return its corresponding clone.
  794. stack || (stack = new Stack);
  795. var stacked = stack.get(value);
  796. if (stacked) {
  797. return stacked;
  798. }
  799. stack.set(value, result);
  800. if (!isArr) {
  801. var props = isFull ? getAllKeys(value) : keys(value);
  802. }
  803. arrayEach(props || value, function(subValue, key) {
  804. if (props) {
  805. key = subValue;
  806. subValue = value[key];
  807. }
  808. // Recursively populate clone (susceptible to call stack limits).
  809. assignValue(result, key, baseClone(subValue, isDeep, isFull, customizer, key, value, stack));
  810. });
  811. return result;
  812. }
  813. /**
  814. * The base implementation of `_.create` without support for assigning
  815. * properties to the created object.
  816. *
  817. * @private
  818. * @param {Object} prototype The object to inherit from.
  819. * @returns {Object} Returns the new object.
  820. */
  821. function baseCreate(proto) {
  822. return isObject(proto) ? objectCreate(proto) : {};
  823. }
  824. /**
  825. * The base implementation of `getAllKeys` and `getAllKeysIn` which uses
  826. * `keysFunc` and `symbolsFunc` to get the enumerable property names and
  827. * symbols of `object`.
  828. *
  829. * @private
  830. * @param {Object} object The object to query.
  831. * @param {Function} keysFunc The function to get the keys of `object`.
  832. * @param {Function} symbolsFunc The function to get the symbols of `object`.
  833. * @returns {Array} Returns the array of property names and symbols.
  834. */
  835. function baseGetAllKeys(object, keysFunc, symbolsFunc) {
  836. var result = keysFunc(object);
  837. return isArray(object) ? result : arrayPush(result, symbolsFunc(object));
  838. }
  839. /**
  840. * The base implementation of `getTag`.
  841. *
  842. * @private
  843. * @param {*} value The value to query.
  844. * @returns {string} Returns the `toStringTag`.
  845. */
  846. function baseGetTag(value) {
  847. return objectToString.call(value);
  848. }
  849. /**
  850. * The base implementation of `_.isNative` without bad shim checks.
  851. *
  852. * @private
  853. * @param {*} value The value to check.
  854. * @returns {boolean} Returns `true` if `value` is a native function,
  855. * else `false`.
  856. */
  857. function baseIsNative(value) {
  858. if (!isObject(value) || isMasked(value)) {
  859. return false;
  860. }
  861. var pattern = (isFunction(value) || isHostObject(value)) ? reIsNative : reIsHostCtor;
  862. return pattern.test(toSource(value));
  863. }
  864. /**
  865. * The base implementation of `_.keys` which doesn't treat sparse arrays as dense.
  866. *
  867. * @private
  868. * @param {Object} object The object to query.
  869. * @returns {Array} Returns the array of property names.
  870. */
  871. function baseKeys(object) {
  872. if (!isPrototype(object)) {
  873. return nativeKeys(object);
  874. }
  875. var result = [];
  876. for (var key in Object(object)) {
  877. if (hasOwnProperty.call(object, key) && key != 'constructor') {
  878. result.push(key);
  879. }
  880. }
  881. return result;
  882. }
  883. /**
  884. * Creates a clone of `buffer`.
  885. *
  886. * @private
  887. * @param {Buffer} buffer The buffer to clone.
  888. * @param {boolean} [isDeep] Specify a deep clone.
  889. * @returns {Buffer} Returns the cloned buffer.
  890. */
  891. function cloneBuffer(buffer, isDeep) {
  892. if (isDeep) {
  893. return buffer.slice();
  894. }
  895. var result = new buffer.constructor(buffer.length);
  896. buffer.copy(result);
  897. return result;
  898. }
  899. /**
  900. * Creates a clone of `arrayBuffer`.
  901. *
  902. * @private
  903. * @param {ArrayBuffer} arrayBuffer The array buffer to clone.
  904. * @returns {ArrayBuffer} Returns the cloned array buffer.
  905. */
  906. function cloneArrayBuffer(arrayBuffer) {
  907. var result = new arrayBuffer.constructor(arrayBuffer.byteLength);
  908. new Uint8Array(result).set(new Uint8Array(arrayBuffer));
  909. return result;
  910. }
  911. /**
  912. * Creates a clone of `dataView`.
  913. *
  914. * @private
  915. * @param {Object} dataView The data view to clone.
  916. * @param {boolean} [isDeep] Specify a deep clone.
  917. * @returns {Object} Returns the cloned data view.
  918. */
  919. function cloneDataView(dataView, isDeep) {
  920. var buffer = isDeep ? cloneArrayBuffer(dataView.buffer) : dataView.buffer;
  921. return new dataView.constructor(buffer, dataView.byteOffset, dataView.byteLength);
  922. }
  923. /**
  924. * Creates a clone of `map`.
  925. *
  926. * @private
  927. * @param {Object} map The map to clone.
  928. * @param {Function} cloneFunc The function to clone values.
  929. * @param {boolean} [isDeep] Specify a deep clone.
  930. * @returns {Object} Returns the cloned map.
  931. */
  932. function cloneMap(map, isDeep, cloneFunc) {
  933. var array = isDeep ? cloneFunc(mapToArray(map), true) : mapToArray(map);
  934. return arrayReduce(array, addMapEntry, new map.constructor);
  935. }
  936. /**
  937. * Creates a clone of `regexp`.
  938. *
  939. * @private
  940. * @param {Object} regexp The regexp to clone.
  941. * @returns {Object} Returns the cloned regexp.
  942. */
  943. function cloneRegExp(regexp) {
  944. var result = new regexp.constructor(regexp.source, reFlags.exec(regexp));
  945. result.lastIndex = regexp.lastIndex;
  946. return result;
  947. }
  948. /**
  949. * Creates a clone of `set`.
  950. *
  951. * @private
  952. * @param {Object} set The set to clone.
  953. * @param {Function} cloneFunc The function to clone values.
  954. * @param {boolean} [isDeep] Specify a deep clone.
  955. * @returns {Object} Returns the cloned set.
  956. */
  957. function cloneSet(set, isDeep, cloneFunc) {
  958. var array = isDeep ? cloneFunc(setToArray(set), true) : setToArray(set);
  959. return arrayReduce(array, addSetEntry, new set.constructor);
  960. }
  961. /**
  962. * Creates a clone of the `symbol` object.
  963. *
  964. * @private
  965. * @param {Object} symbol The symbol object to clone.
  966. * @returns {Object} Returns the cloned symbol object.
  967. */
  968. function cloneSymbol(symbol) {
  969. return symbolValueOf ? Object(symbolValueOf.call(symbol)) : {};
  970. }
  971. /**
  972. * Creates a clone of `typedArray`.
  973. *
  974. * @private
  975. * @param {Object} typedArray The typed array to clone.
  976. * @param {boolean} [isDeep] Specify a deep clone.
  977. * @returns {Object} Returns the cloned typed array.
  978. */
  979. function cloneTypedArray(typedArray, isDeep) {
  980. var buffer = isDeep ? cloneArrayBuffer(typedArray.buffer) : typedArray.buffer;
  981. return new typedArray.constructor(buffer, typedArray.byteOffset, typedArray.length);
  982. }
  983. /**
  984. * Copies the values of `source` to `array`.
  985. *
  986. * @private
  987. * @param {Array} source The array to copy values from.
  988. * @param {Array} [array=[]] The array to copy values to.
  989. * @returns {Array} Returns `array`.
  990. */
  991. function copyArray(source, array) {
  992. var index = -1,
  993. length = source.length;
  994. array || (array = Array(length));
  995. while (++index < length) {
  996. array[index] = source[index];
  997. }
  998. return array;
  999. }
  1000. /**
  1001. * Copies properties of `source` to `object`.
  1002. *
  1003. * @private
  1004. * @param {Object} source The object to copy properties from.
  1005. * @param {Array} props The property identifiers to copy.
  1006. * @param {Object} [object={}] The object to copy properties to.
  1007. * @param {Function} [customizer] The function to customize copied values.
  1008. * @returns {Object} Returns `object`.
  1009. */
  1010. function copyObject(source, props, object, customizer) {
  1011. object || (object = {});
  1012. var index = -1,
  1013. length = props.length;
  1014. while (++index < length) {
  1015. var key = props[index];
  1016. var newValue = customizer
  1017. ? customizer(object[key], source[key], key, object, source)
  1018. : undefined;
  1019. assignValue(object, key, newValue === undefined ? source[key] : newValue);
  1020. }
  1021. return object;
  1022. }
  1023. /**
  1024. * Copies own symbol properties of `source` to `object`.
  1025. *
  1026. * @private
  1027. * @param {Object} source The object to copy symbols from.
  1028. * @param {Object} [object={}] The object to copy symbols to.
  1029. * @returns {Object} Returns `object`.
  1030. */
  1031. function copySymbols(source, object) {
  1032. return copyObject(source, getSymbols(source), object);
  1033. }
  1034. /**
  1035. * Creates an array of own enumerable property names and symbols of `object`.
  1036. *
  1037. * @private
  1038. * @param {Object} object The object to query.
  1039. * @returns {Array} Returns the array of property names and symbols.
  1040. */
  1041. function getAllKeys(object) {
  1042. return baseGetAllKeys(object, keys, getSymbols);
  1043. }
  1044. /**
  1045. * Gets the data for `map`.
  1046. *
  1047. * @private
  1048. * @param {Object} map The map to query.
  1049. * @param {string} key The reference key.
  1050. * @returns {*} Returns the map data.
  1051. */
  1052. function getMapData(map, key) {
  1053. var data = map.__data__;
  1054. return isKeyable(key)
  1055. ? data[typeof key == 'string' ? 'string' : 'hash']
  1056. : data.map;
  1057. }
  1058. /**
  1059. * Gets the native function at `key` of `object`.
  1060. *
  1061. * @private
  1062. * @param {Object} object The object to query.
  1063. * @param {string} key The key of the method to get.
  1064. * @returns {*} Returns the function if it's native, else `undefined`.
  1065. */
  1066. function getNative(object, key) {
  1067. var value = getValue(object, key);
  1068. return baseIsNative(value) ? value : undefined;
  1069. }
  1070. /**
  1071. * Creates an array of the own enumerable symbol properties of `object`.
  1072. *
  1073. * @private
  1074. * @param {Object} object The object to query.
  1075. * @returns {Array} Returns the array of symbols.
  1076. */
  1077. var getSymbols = nativeGetSymbols ? overArg(nativeGetSymbols, Object) : stubArray;
  1078. /**
  1079. * Gets the `toStringTag` of `value`.
  1080. *
  1081. * @private
  1082. * @param {*} value The value to query.
  1083. * @returns {string} Returns the `toStringTag`.
  1084. */
  1085. var getTag = baseGetTag;
  1086. // Fallback for data views, maps, sets, and weak maps in IE 11,
  1087. // for data views in Edge < 14, and promises in Node.js.
  1088. if ((DataView && getTag(new DataView(new ArrayBuffer(1))) != dataViewTag) ||
  1089. (Map && getTag(new Map) != mapTag) ||
  1090. (Promise && getTag(Promise.resolve()) != promiseTag) ||
  1091. (Set && getTag(new Set) != setTag) ||
  1092. (WeakMap && getTag(new WeakMap) != weakMapTag)) {
  1093. getTag = function(value) {
  1094. var result = objectToString.call(value),
  1095. Ctor = result == objectTag ? value.constructor : undefined,
  1096. ctorString = Ctor ? toSource(Ctor) : undefined;
  1097. if (ctorString) {
  1098. switch (ctorString) {
  1099. case dataViewCtorString: return dataViewTag;
  1100. case mapCtorString: return mapTag;
  1101. case promiseCtorString: return promiseTag;
  1102. case setCtorString: return setTag;
  1103. case weakMapCtorString: return weakMapTag;
  1104. }
  1105. }
  1106. return result;
  1107. };
  1108. }
  1109. /**
  1110. * Initializes an array clone.
  1111. *
  1112. * @private
  1113. * @param {Array} array The array to clone.
  1114. * @returns {Array} Returns the initialized clone.
  1115. */
  1116. function initCloneArray(array) {
  1117. var length = array.length,
  1118. result = array.constructor(length);
  1119. // Add properties assigned by `RegExp#exec`.
  1120. if (length && typeof array[0] == 'string' && hasOwnProperty.call(array, 'index')) {
  1121. result.index = array.index;
  1122. result.input = array.input;
  1123. }
  1124. return result;
  1125. }
  1126. /**
  1127. * Initializes an object clone.
  1128. *
  1129. * @private
  1130. * @param {Object} object The object to clone.
  1131. * @returns {Object} Returns the initialized clone.
  1132. */
  1133. function initCloneObject(object) {
  1134. return (typeof object.constructor == 'function' && !isPrototype(object))
  1135. ? baseCreate(getPrototype(object))
  1136. : {};
  1137. }
  1138. /**
  1139. * Initializes an object clone based on its `toStringTag`.
  1140. *
  1141. * **Note:** This function only supports cloning values with tags of
  1142. * `Boolean`, `Date`, `Error`, `Number`, `RegExp`, or `String`.
  1143. *
  1144. * @private
  1145. * @param {Object} object The object to clone.
  1146. * @param {string} tag The `toStringTag` of the object to clone.
  1147. * @param {Function} cloneFunc The function to clone values.
  1148. * @param {boolean} [isDeep] Specify a deep clone.
  1149. * @returns {Object} Returns the initialized clone.
  1150. */
  1151. function initCloneByTag(object, tag, cloneFunc, isDeep) {
  1152. var Ctor = object.constructor;
  1153. switch (tag) {
  1154. case arrayBufferTag:
  1155. return cloneArrayBuffer(object);
  1156. case boolTag:
  1157. case dateTag:
  1158. return new Ctor(+object);
  1159. case dataViewTag:
  1160. return cloneDataView(object, isDeep);
  1161. case float32Tag: case float64Tag:
  1162. case int8Tag: case int16Tag: case int32Tag:
  1163. case uint8Tag: case uint8ClampedTag: case uint16Tag: case uint32Tag:
  1164. return cloneTypedArray(object, isDeep);
  1165. case mapTag:
  1166. return cloneMap(object, isDeep, cloneFunc);
  1167. case numberTag:
  1168. case stringTag:
  1169. return new Ctor(object);
  1170. case regexpTag:
  1171. return cloneRegExp(object);
  1172. case setTag:
  1173. return cloneSet(object, isDeep, cloneFunc);
  1174. case symbolTag:
  1175. return cloneSymbol(object);
  1176. }
  1177. }
  1178. /**
  1179. * Checks if `value` is a valid array-like index.
  1180. *
  1181. * @private
  1182. * @param {*} value The value to check.
  1183. * @param {number} [length=MAX_SAFE_INTEGER] The upper bounds of a valid index.
  1184. * @returns {boolean} Returns `true` if `value` is a valid index, else `false`.
  1185. */
  1186. function isIndex(value, length) {
  1187. length = length == null ? MAX_SAFE_INTEGER : length;
  1188. return !!length &&
  1189. (typeof value == 'number' || reIsUint.test(value)) &&
  1190. (value > -1 && value % 1 == 0 && value < length);
  1191. }
  1192. /**
  1193. * Checks if `value` is suitable for use as unique object key.
  1194. *
  1195. * @private
  1196. * @param {*} value The value to check.
  1197. * @returns {boolean} Returns `true` if `value` is suitable, else `false`.
  1198. */
  1199. function isKeyable(value) {
  1200. var type = typeof value;
  1201. return (type == 'string' || type == 'number' || type == 'symbol' || type == 'boolean')
  1202. ? (value !== '__proto__')
  1203. : (value === null);
  1204. }
  1205. /**
  1206. * Checks if `func` has its source masked.
  1207. *
  1208. * @private
  1209. * @param {Function} func The function to check.
  1210. * @returns {boolean} Returns `true` if `func` is masked, else `false`.
  1211. */
  1212. function isMasked(func) {
  1213. return !!maskSrcKey && (maskSrcKey in func);
  1214. }
  1215. /**
  1216. * Checks if `value` is likely a prototype object.
  1217. *
  1218. * @private
  1219. * @param {*} value The value to check.
  1220. * @returns {boolean} Returns `true` if `value` is a prototype, else `false`.
  1221. */
  1222. function isPrototype(value) {
  1223. var Ctor = value && value.constructor,
  1224. proto = (typeof Ctor == 'function' && Ctor.prototype) || objectProto;
  1225. return value === proto;
  1226. }
  1227. /**
  1228. * Converts `func` to its source code.
  1229. *
  1230. * @private
  1231. * @param {Function} func The function to process.
  1232. * @returns {string} Returns the source code.
  1233. */
  1234. function toSource(func) {
  1235. if (func != null) {
  1236. try {
  1237. return funcToString.call(func);
  1238. } catch (e) {}
  1239. try {
  1240. return (func + '');
  1241. } catch (e) {}
  1242. }
  1243. return '';
  1244. }
  1245. /**
  1246. * This method is like `_.clone` except that it recursively clones `value`.
  1247. *
  1248. * @static
  1249. * @memberOf _
  1250. * @since 1.0.0
  1251. * @category Lang
  1252. * @param {*} value The value to recursively clone.
  1253. * @returns {*} Returns the deep cloned value.
  1254. * @see _.clone
  1255. * @example
  1256. *
  1257. * var objects = [{ 'a': 1 }, { 'b': 2 }];
  1258. *
  1259. * var deep = _.cloneDeep(objects);
  1260. * console.log(deep[0] === objects[0]);
  1261. * // => false
  1262. */
  1263. function cloneDeep(value) {
  1264. return baseClone(value, true, true);
  1265. }
  1266. /**
  1267. * Performs a
  1268. * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
  1269. * comparison between two values to determine if they are equivalent.
  1270. *
  1271. * @static
  1272. * @memberOf _
  1273. * @since 4.0.0
  1274. * @category Lang
  1275. * @param {*} value The value to compare.
  1276. * @param {*} other The other value to compare.
  1277. * @returns {boolean} Returns `true` if the values are equivalent, else `false`.
  1278. * @example
  1279. *
  1280. * var object = { 'a': 1 };
  1281. * var other = { 'a': 1 };
  1282. *
  1283. * _.eq(object, object);
  1284. * // => true
  1285. *
  1286. * _.eq(object, other);
  1287. * // => false
  1288. *
  1289. * _.eq('a', 'a');
  1290. * // => true
  1291. *
  1292. * _.eq('a', Object('a'));
  1293. * // => false
  1294. *
  1295. * _.eq(NaN, NaN);
  1296. * // => true
  1297. */
  1298. function eq(value, other) {
  1299. return value === other || (value !== value && other !== other);
  1300. }
  1301. /**
  1302. * Checks if `value` is likely an `arguments` object.
  1303. *
  1304. * @static
  1305. * @memberOf _
  1306. * @since 0.1.0
  1307. * @category Lang
  1308. * @param {*} value The value to check.
  1309. * @returns {boolean} Returns `true` if `value` is an `arguments` object,
  1310. * else `false`.
  1311. * @example
  1312. *
  1313. * _.isArguments(function() { return arguments; }());
  1314. * // => true
  1315. *
  1316. * _.isArguments([1, 2, 3]);
  1317. * // => false
  1318. */
  1319. function isArguments(value) {
  1320. // Safari 8.1 makes `arguments.callee` enumerable in strict mode.
  1321. return isArrayLikeObject(value) && hasOwnProperty.call(value, 'callee') &&
  1322. (!propertyIsEnumerable.call(value, 'callee') || objectToString.call(value) == argsTag);
  1323. }
  1324. /**
  1325. * Checks if `value` is classified as an `Array` object.
  1326. *
  1327. * @static
  1328. * @memberOf _
  1329. * @since 0.1.0
  1330. * @category Lang
  1331. * @param {*} value The value to check.
  1332. * @returns {boolean} Returns `true` if `value` is an array, else `false`.
  1333. * @example
  1334. *
  1335. * _.isArray([1, 2, 3]);
  1336. * // => true
  1337. *
  1338. * _.isArray(document.body.children);
  1339. * // => false
  1340. *
  1341. * _.isArray('abc');
  1342. * // => false
  1343. *
  1344. * _.isArray(_.noop);
  1345. * // => false
  1346. */
  1347. var isArray = Array.isArray;
  1348. /**
  1349. * Checks if `value` is array-like. A value is considered array-like if it's
  1350. * not a function and has a `value.length` that's an integer greater than or
  1351. * equal to `0` and less than or equal to `Number.MAX_SAFE_INTEGER`.
  1352. *
  1353. * @static
  1354. * @memberOf _
  1355. * @since 4.0.0
  1356. * @category Lang
  1357. * @param {*} value The value to check.
  1358. * @returns {boolean} Returns `true` if `value` is array-like, else `false`.
  1359. * @example
  1360. *
  1361. * _.isArrayLike([1, 2, 3]);
  1362. * // => true
  1363. *
  1364. * _.isArrayLike(document.body.children);
  1365. * // => true
  1366. *
  1367. * _.isArrayLike('abc');
  1368. * // => true
  1369. *
  1370. * _.isArrayLike(_.noop);
  1371. * // => false
  1372. */
  1373. function isArrayLike(value) {
  1374. return value != null && isLength(value.length) && !isFunction(value);
  1375. }
  1376. /**
  1377. * This method is like `_.isArrayLike` except that it also checks if `value`
  1378. * is an object.
  1379. *
  1380. * @static
  1381. * @memberOf _
  1382. * @since 4.0.0
  1383. * @category Lang
  1384. * @param {*} value The value to check.
  1385. * @returns {boolean} Returns `true` if `value` is an array-like object,
  1386. * else `false`.
  1387. * @example
  1388. *
  1389. * _.isArrayLikeObject([1, 2, 3]);
  1390. * // => true
  1391. *
  1392. * _.isArrayLikeObject(document.body.children);
  1393. * // => true
  1394. *
  1395. * _.isArrayLikeObject('abc');
  1396. * // => false
  1397. *
  1398. * _.isArrayLikeObject(_.noop);
  1399. * // => false
  1400. */
  1401. function isArrayLikeObject(value) {
  1402. return isObjectLike(value) && isArrayLike(value);
  1403. }
  1404. /**
  1405. * Checks if `value` is a buffer.
  1406. *
  1407. * @static
  1408. * @memberOf _
  1409. * @since 4.3.0
  1410. * @category Lang
  1411. * @param {*} value The value to check.
  1412. * @returns {boolean} Returns `true` if `value` is a buffer, else `false`.
  1413. * @example
  1414. *
  1415. * _.isBuffer(new Buffer(2));
  1416. * // => true
  1417. *
  1418. * _.isBuffer(new Uint8Array(2));
  1419. * // => false
  1420. */
  1421. var isBuffer = nativeIsBuffer || stubFalse;
  1422. /**
  1423. * Checks if `value` is classified as a `Function` object.
  1424. *
  1425. * @static
  1426. * @memberOf _
  1427. * @since 0.1.0
  1428. * @category Lang
  1429. * @param {*} value The value to check.
  1430. * @returns {boolean} Returns `true` if `value` is a function, else `false`.
  1431. * @example
  1432. *
  1433. * _.isFunction(_);
  1434. * // => true
  1435. *
  1436. * _.isFunction(/abc/);
  1437. * // => false
  1438. */
  1439. function isFunction(value) {
  1440. // The use of `Object#toString` avoids issues with the `typeof` operator
  1441. // in Safari 8-9 which returns 'object' for typed array and other constructors.
  1442. var tag = isObject(value) ? objectToString.call(value) : '';
  1443. return tag == funcTag || tag == genTag;
  1444. }
  1445. /**
  1446. * Checks if `value` is a valid array-like length.
  1447. *
  1448. * **Note:** This method is loosely based on
  1449. * [`ToLength`](http://ecma-international.org/ecma-262/7.0/#sec-tolength).
  1450. *
  1451. * @static
  1452. * @memberOf _
  1453. * @since 4.0.0
  1454. * @category Lang
  1455. * @param {*} value The value to check.
  1456. * @returns {boolean} Returns `true` if `value` is a valid length, else `false`.
  1457. * @example
  1458. *
  1459. * _.isLength(3);
  1460. * // => true
  1461. *
  1462. * _.isLength(Number.MIN_VALUE);
  1463. * // => false
  1464. *
  1465. * _.isLength(Infinity);
  1466. * // => false
  1467. *
  1468. * _.isLength('3');
  1469. * // => false
  1470. */
  1471. function isLength(value) {
  1472. return typeof value == 'number' &&
  1473. value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER;
  1474. }
  1475. /**
  1476. * Checks if `value` is the
  1477. * [language type](http://www.ecma-international.org/ecma-262/7.0/#sec-ecmascript-language-types)
  1478. * of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)
  1479. *
  1480. * @static
  1481. * @memberOf _
  1482. * @since 0.1.0
  1483. * @category Lang
  1484. * @param {*} value The value to check.
  1485. * @returns {boolean} Returns `true` if `value` is an object, else `false`.
  1486. * @example
  1487. *
  1488. * _.isObject({});
  1489. * // => true
  1490. *
  1491. * _.isObject([1, 2, 3]);
  1492. * // => true
  1493. *
  1494. * _.isObject(_.noop);
  1495. * // => true
  1496. *
  1497. * _.isObject(null);
  1498. * // => false
  1499. */
  1500. function isObject(value) {
  1501. var type = typeof value;
  1502. return !!value && (type == 'object' || type == 'function');
  1503. }
  1504. /**
  1505. * Checks if `value` is object-like. A value is object-like if it's not `null`
  1506. * and has a `typeof` result of "object".
  1507. *
  1508. * @static
  1509. * @memberOf _
  1510. * @since 4.0.0
  1511. * @category Lang
  1512. * @param {*} value The value to check.
  1513. * @returns {boolean} Returns `true` if `value` is object-like, else `false`.
  1514. * @example
  1515. *
  1516. * _.isObjectLike({});
  1517. * // => true
  1518. *
  1519. * _.isObjectLike([1, 2, 3]);
  1520. * // => true
  1521. *
  1522. * _.isObjectLike(_.noop);
  1523. * // => false
  1524. *
  1525. * _.isObjectLike(null);
  1526. * // => false
  1527. */
  1528. function isObjectLike(value) {
  1529. return !!value && typeof value == 'object';
  1530. }
  1531. /**
  1532. * Creates an array of the own enumerable property names of `object`.
  1533. *
  1534. * **Note:** Non-object values are coerced to objects. See the
  1535. * [ES spec](http://ecma-international.org/ecma-262/7.0/#sec-object.keys)
  1536. * for more details.
  1537. *
  1538. * @static
  1539. * @since 0.1.0
  1540. * @memberOf _
  1541. * @category Object
  1542. * @param {Object} object The object to query.
  1543. * @returns {Array} Returns the array of property names.
  1544. * @example
  1545. *
  1546. * function Foo() {
  1547. * this.a = 1;
  1548. * this.b = 2;
  1549. * }
  1550. *
  1551. * Foo.prototype.c = 3;
  1552. *
  1553. * _.keys(new Foo);
  1554. * // => ['a', 'b'] (iteration order is not guaranteed)
  1555. *
  1556. * _.keys('hi');
  1557. * // => ['0', '1']
  1558. */
  1559. function keys(object) {
  1560. return isArrayLike(object) ? arrayLikeKeys(object) : baseKeys(object);
  1561. }
  1562. /**
  1563. * This method returns a new empty array.
  1564. *
  1565. * @static
  1566. * @memberOf _
  1567. * @since 4.13.0
  1568. * @category Util
  1569. * @returns {Array} Returns the new empty array.
  1570. * @example
  1571. *
  1572. * var arrays = _.times(2, _.stubArray);
  1573. *
  1574. * console.log(arrays);
  1575. * // => [[], []]
  1576. *
  1577. * console.log(arrays[0] === arrays[1]);
  1578. * // => false
  1579. */
  1580. function stubArray() {
  1581. return [];
  1582. }
  1583. /**
  1584. * This method returns `false`.
  1585. *
  1586. * @static
  1587. * @memberOf _
  1588. * @since 4.13.0
  1589. * @category Util
  1590. * @returns {boolean} Returns `false`.
  1591. * @example
  1592. *
  1593. * _.times(2, _.stubFalse);
  1594. * // => [false, false]
  1595. */
  1596. function stubFalse() {
  1597. return false;
  1598. }
  1599. module.exports = cloneDeep;