Software zum Installieren eines Smart-Mirror Frameworks , zum Nutzen von hochschulrelevanten Informationen, auf einem Raspberry-Pi.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

index.js 50KB

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