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 29KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181
  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 INFINITY = 1 / 0,
  15. MAX_SAFE_INTEGER = 9007199254740991;
  16. /** `Object#toString` result references. */
  17. var argsTag = '[object Arguments]',
  18. funcTag = '[object Function]',
  19. genTag = '[object GeneratorFunction]';
  20. /**
  21. * Used to match `RegExp`
  22. * [syntax characters](http://ecma-international.org/ecma-262/7.0/#sec-patterns).
  23. */
  24. var reRegExpChar = /[\\^$.*+?()[\]{}|]/g;
  25. /** Used to detect host constructors (Safari). */
  26. var reIsHostCtor = /^\[object .+?Constructor\]$/;
  27. /** Detect free variable `global` from Node.js. */
  28. var freeGlobal = typeof global == 'object' && global && global.Object === Object && global;
  29. /** Detect free variable `self`. */
  30. var freeSelf = typeof self == 'object' && self && self.Object === Object && self;
  31. /** Used as a reference to the global object. */
  32. var root = freeGlobal || freeSelf || Function('return this')();
  33. /**
  34. * A faster alternative to `Function#apply`, this function invokes `func`
  35. * with the `this` binding of `thisArg` and the arguments of `args`.
  36. *
  37. * @private
  38. * @param {Function} func The function to invoke.
  39. * @param {*} thisArg The `this` binding of `func`.
  40. * @param {Array} args The arguments to invoke `func` with.
  41. * @returns {*} Returns the result of `func`.
  42. */
  43. function apply(func, thisArg, args) {
  44. switch (args.length) {
  45. case 0: return func.call(thisArg);
  46. case 1: return func.call(thisArg, args[0]);
  47. case 2: return func.call(thisArg, args[0], args[1]);
  48. case 3: return func.call(thisArg, args[0], args[1], args[2]);
  49. }
  50. return func.apply(thisArg, args);
  51. }
  52. /**
  53. * A specialized version of `_.includes` for arrays without support for
  54. * specifying an index to search from.
  55. *
  56. * @private
  57. * @param {Array} [array] The array to inspect.
  58. * @param {*} target The value to search for.
  59. * @returns {boolean} Returns `true` if `target` is found, else `false`.
  60. */
  61. function arrayIncludes(array, value) {
  62. var length = array ? array.length : 0;
  63. return !!length && baseIndexOf(array, value, 0) > -1;
  64. }
  65. /**
  66. * This function is like `arrayIncludes` except that it accepts a comparator.
  67. *
  68. * @private
  69. * @param {Array} [array] The array to inspect.
  70. * @param {*} target The value to search for.
  71. * @param {Function} comparator The comparator invoked per element.
  72. * @returns {boolean} Returns `true` if `target` is found, else `false`.
  73. */
  74. function arrayIncludesWith(array, value, comparator) {
  75. var index = -1,
  76. length = array ? array.length : 0;
  77. while (++index < length) {
  78. if (comparator(value, array[index])) {
  79. return true;
  80. }
  81. }
  82. return false;
  83. }
  84. /**
  85. * Appends the elements of `values` to `array`.
  86. *
  87. * @private
  88. * @param {Array} array The array to modify.
  89. * @param {Array} values The values to append.
  90. * @returns {Array} Returns `array`.
  91. */
  92. function arrayPush(array, values) {
  93. var index = -1,
  94. length = values.length,
  95. offset = array.length;
  96. while (++index < length) {
  97. array[offset + index] = values[index];
  98. }
  99. return array;
  100. }
  101. /**
  102. * The base implementation of `_.findIndex` and `_.findLastIndex` without
  103. * support for iteratee shorthands.
  104. *
  105. * @private
  106. * @param {Array} array The array to inspect.
  107. * @param {Function} predicate The function invoked per iteration.
  108. * @param {number} fromIndex The index to search from.
  109. * @param {boolean} [fromRight] Specify iterating from right to left.
  110. * @returns {number} Returns the index of the matched value, else `-1`.
  111. */
  112. function baseFindIndex(array, predicate, fromIndex, fromRight) {
  113. var length = array.length,
  114. index = fromIndex + (fromRight ? 1 : -1);
  115. while ((fromRight ? index-- : ++index < length)) {
  116. if (predicate(array[index], index, array)) {
  117. return index;
  118. }
  119. }
  120. return -1;
  121. }
  122. /**
  123. * The base implementation of `_.indexOf` without `fromIndex` bounds checks.
  124. *
  125. * @private
  126. * @param {Array} array The array to inspect.
  127. * @param {*} value The value to search for.
  128. * @param {number} fromIndex The index to search from.
  129. * @returns {number} Returns the index of the matched value, else `-1`.
  130. */
  131. function baseIndexOf(array, value, fromIndex) {
  132. if (value !== value) {
  133. return baseFindIndex(array, baseIsNaN, fromIndex);
  134. }
  135. var index = fromIndex - 1,
  136. length = array.length;
  137. while (++index < length) {
  138. if (array[index] === value) {
  139. return index;
  140. }
  141. }
  142. return -1;
  143. }
  144. /**
  145. * The base implementation of `_.isNaN` without support for number objects.
  146. *
  147. * @private
  148. * @param {*} value The value to check.
  149. * @returns {boolean} Returns `true` if `value` is `NaN`, else `false`.
  150. */
  151. function baseIsNaN(value) {
  152. return value !== value;
  153. }
  154. /**
  155. * Checks if a cache value for `key` exists.
  156. *
  157. * @private
  158. * @param {Object} cache The cache to query.
  159. * @param {string} key The key of the entry to check.
  160. * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
  161. */
  162. function cacheHas(cache, key) {
  163. return cache.has(key);
  164. }
  165. /**
  166. * Gets the value at `key` of `object`.
  167. *
  168. * @private
  169. * @param {Object} [object] The object to query.
  170. * @param {string} key The key of the property to get.
  171. * @returns {*} Returns the property value.
  172. */
  173. function getValue(object, key) {
  174. return object == null ? undefined : object[key];
  175. }
  176. /**
  177. * Checks if `value` is a host object in IE < 9.
  178. *
  179. * @private
  180. * @param {*} value The value to check.
  181. * @returns {boolean} Returns `true` if `value` is a host object, else `false`.
  182. */
  183. function isHostObject(value) {
  184. // Many host objects are `Object` objects that can coerce to strings
  185. // despite having improperly defined `toString` methods.
  186. var result = false;
  187. if (value != null && typeof value.toString != 'function') {
  188. try {
  189. result = !!(value + '');
  190. } catch (e) {}
  191. }
  192. return result;
  193. }
  194. /**
  195. * Converts `set` to an array of its values.
  196. *
  197. * @private
  198. * @param {Object} set The set to convert.
  199. * @returns {Array} Returns the values.
  200. */
  201. function setToArray(set) {
  202. var index = -1,
  203. result = Array(set.size);
  204. set.forEach(function(value) {
  205. result[++index] = value;
  206. });
  207. return result;
  208. }
  209. /** Used for built-in method references. */
  210. var arrayProto = Array.prototype,
  211. funcProto = Function.prototype,
  212. objectProto = Object.prototype;
  213. /** Used to detect overreaching core-js shims. */
  214. var coreJsData = root['__core-js_shared__'];
  215. /** Used to detect methods masquerading as native. */
  216. var maskSrcKey = (function() {
  217. var uid = /[^.]+$/.exec(coreJsData && coreJsData.keys && coreJsData.keys.IE_PROTO || '');
  218. return uid ? ('Symbol(src)_1.' + uid) : '';
  219. }());
  220. /** Used to resolve the decompiled source of functions. */
  221. var funcToString = funcProto.toString;
  222. /** Used to check objects for own properties. */
  223. var hasOwnProperty = objectProto.hasOwnProperty;
  224. /**
  225. * Used to resolve the
  226. * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
  227. * of values.
  228. */
  229. var objectToString = objectProto.toString;
  230. /** Used to detect if a method is native. */
  231. var reIsNative = RegExp('^' +
  232. funcToString.call(hasOwnProperty).replace(reRegExpChar, '\\$&')
  233. .replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, '$1.*?') + '$'
  234. );
  235. /** Built-in value references. */
  236. var Symbol = root.Symbol,
  237. propertyIsEnumerable = objectProto.propertyIsEnumerable,
  238. splice = arrayProto.splice,
  239. spreadableSymbol = Symbol ? Symbol.isConcatSpreadable : undefined;
  240. /* Built-in method references for those with the same name as other `lodash` methods. */
  241. var nativeMax = Math.max;
  242. /* Built-in method references that are verified to be native. */
  243. var Map = getNative(root, 'Map'),
  244. Set = getNative(root, 'Set'),
  245. nativeCreate = getNative(Object, 'create');
  246. /**
  247. * Creates a hash object.
  248. *
  249. * @private
  250. * @constructor
  251. * @param {Array} [entries] The key-value pairs to cache.
  252. */
  253. function Hash(entries) {
  254. var index = -1,
  255. length = entries ? entries.length : 0;
  256. this.clear();
  257. while (++index < length) {
  258. var entry = entries[index];
  259. this.set(entry[0], entry[1]);
  260. }
  261. }
  262. /**
  263. * Removes all key-value entries from the hash.
  264. *
  265. * @private
  266. * @name clear
  267. * @memberOf Hash
  268. */
  269. function hashClear() {
  270. this.__data__ = nativeCreate ? nativeCreate(null) : {};
  271. }
  272. /**
  273. * Removes `key` and its value from the hash.
  274. *
  275. * @private
  276. * @name delete
  277. * @memberOf Hash
  278. * @param {Object} hash The hash to modify.
  279. * @param {string} key The key of the value to remove.
  280. * @returns {boolean} Returns `true` if the entry was removed, else `false`.
  281. */
  282. function hashDelete(key) {
  283. return this.has(key) && delete this.__data__[key];
  284. }
  285. /**
  286. * Gets the hash value for `key`.
  287. *
  288. * @private
  289. * @name get
  290. * @memberOf Hash
  291. * @param {string} key The key of the value to get.
  292. * @returns {*} Returns the entry value.
  293. */
  294. function hashGet(key) {
  295. var data = this.__data__;
  296. if (nativeCreate) {
  297. var result = data[key];
  298. return result === HASH_UNDEFINED ? undefined : result;
  299. }
  300. return hasOwnProperty.call(data, key) ? data[key] : undefined;
  301. }
  302. /**
  303. * Checks if a hash value for `key` exists.
  304. *
  305. * @private
  306. * @name has
  307. * @memberOf Hash
  308. * @param {string} key The key of the entry to check.
  309. * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
  310. */
  311. function hashHas(key) {
  312. var data = this.__data__;
  313. return nativeCreate ? data[key] !== undefined : hasOwnProperty.call(data, key);
  314. }
  315. /**
  316. * Sets the hash `key` to `value`.
  317. *
  318. * @private
  319. * @name set
  320. * @memberOf Hash
  321. * @param {string} key The key of the value to set.
  322. * @param {*} value The value to set.
  323. * @returns {Object} Returns the hash instance.
  324. */
  325. function hashSet(key, value) {
  326. var data = this.__data__;
  327. data[key] = (nativeCreate && value === undefined) ? HASH_UNDEFINED : value;
  328. return this;
  329. }
  330. // Add methods to `Hash`.
  331. Hash.prototype.clear = hashClear;
  332. Hash.prototype['delete'] = hashDelete;
  333. Hash.prototype.get = hashGet;
  334. Hash.prototype.has = hashHas;
  335. Hash.prototype.set = hashSet;
  336. /**
  337. * Creates an list cache object.
  338. *
  339. * @private
  340. * @constructor
  341. * @param {Array} [entries] The key-value pairs to cache.
  342. */
  343. function ListCache(entries) {
  344. var index = -1,
  345. length = entries ? entries.length : 0;
  346. this.clear();
  347. while (++index < length) {
  348. var entry = entries[index];
  349. this.set(entry[0], entry[1]);
  350. }
  351. }
  352. /**
  353. * Removes all key-value entries from the list cache.
  354. *
  355. * @private
  356. * @name clear
  357. * @memberOf ListCache
  358. */
  359. function listCacheClear() {
  360. this.__data__ = [];
  361. }
  362. /**
  363. * Removes `key` and its value from the list cache.
  364. *
  365. * @private
  366. * @name delete
  367. * @memberOf ListCache
  368. * @param {string} key The key of the value to remove.
  369. * @returns {boolean} Returns `true` if the entry was removed, else `false`.
  370. */
  371. function listCacheDelete(key) {
  372. var data = this.__data__,
  373. index = assocIndexOf(data, key);
  374. if (index < 0) {
  375. return false;
  376. }
  377. var lastIndex = data.length - 1;
  378. if (index == lastIndex) {
  379. data.pop();
  380. } else {
  381. splice.call(data, index, 1);
  382. }
  383. return true;
  384. }
  385. /**
  386. * Gets the list cache value for `key`.
  387. *
  388. * @private
  389. * @name get
  390. * @memberOf ListCache
  391. * @param {string} key The key of the value to get.
  392. * @returns {*} Returns the entry value.
  393. */
  394. function listCacheGet(key) {
  395. var data = this.__data__,
  396. index = assocIndexOf(data, key);
  397. return index < 0 ? undefined : data[index][1];
  398. }
  399. /**
  400. * Checks if a list cache value for `key` exists.
  401. *
  402. * @private
  403. * @name has
  404. * @memberOf ListCache
  405. * @param {string} key The key of the entry to check.
  406. * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
  407. */
  408. function listCacheHas(key) {
  409. return assocIndexOf(this.__data__, key) > -1;
  410. }
  411. /**
  412. * Sets the list cache `key` to `value`.
  413. *
  414. * @private
  415. * @name set
  416. * @memberOf ListCache
  417. * @param {string} key The key of the value to set.
  418. * @param {*} value The value to set.
  419. * @returns {Object} Returns the list cache instance.
  420. */
  421. function listCacheSet(key, value) {
  422. var data = this.__data__,
  423. index = assocIndexOf(data, key);
  424. if (index < 0) {
  425. data.push([key, value]);
  426. } else {
  427. data[index][1] = value;
  428. }
  429. return this;
  430. }
  431. // Add methods to `ListCache`.
  432. ListCache.prototype.clear = listCacheClear;
  433. ListCache.prototype['delete'] = listCacheDelete;
  434. ListCache.prototype.get = listCacheGet;
  435. ListCache.prototype.has = listCacheHas;
  436. ListCache.prototype.set = listCacheSet;
  437. /**
  438. * Creates a map cache object to store key-value pairs.
  439. *
  440. * @private
  441. * @constructor
  442. * @param {Array} [entries] The key-value pairs to cache.
  443. */
  444. function MapCache(entries) {
  445. var index = -1,
  446. length = entries ? entries.length : 0;
  447. this.clear();
  448. while (++index < length) {
  449. var entry = entries[index];
  450. this.set(entry[0], entry[1]);
  451. }
  452. }
  453. /**
  454. * Removes all key-value entries from the map.
  455. *
  456. * @private
  457. * @name clear
  458. * @memberOf MapCache
  459. */
  460. function mapCacheClear() {
  461. this.__data__ = {
  462. 'hash': new Hash,
  463. 'map': new (Map || ListCache),
  464. 'string': new Hash
  465. };
  466. }
  467. /**
  468. * Removes `key` and its value from the map.
  469. *
  470. * @private
  471. * @name delete
  472. * @memberOf MapCache
  473. * @param {string} key The key of the value to remove.
  474. * @returns {boolean} Returns `true` if the entry was removed, else `false`.
  475. */
  476. function mapCacheDelete(key) {
  477. return getMapData(this, key)['delete'](key);
  478. }
  479. /**
  480. * Gets the map value for `key`.
  481. *
  482. * @private
  483. * @name get
  484. * @memberOf MapCache
  485. * @param {string} key The key of the value to get.
  486. * @returns {*} Returns the entry value.
  487. */
  488. function mapCacheGet(key) {
  489. return getMapData(this, key).get(key);
  490. }
  491. /**
  492. * Checks if a map value for `key` exists.
  493. *
  494. * @private
  495. * @name has
  496. * @memberOf MapCache
  497. * @param {string} key The key of the entry to check.
  498. * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
  499. */
  500. function mapCacheHas(key) {
  501. return getMapData(this, key).has(key);
  502. }
  503. /**
  504. * Sets the map `key` to `value`.
  505. *
  506. * @private
  507. * @name set
  508. * @memberOf MapCache
  509. * @param {string} key The key of the value to set.
  510. * @param {*} value The value to set.
  511. * @returns {Object} Returns the map cache instance.
  512. */
  513. function mapCacheSet(key, value) {
  514. getMapData(this, key).set(key, value);
  515. return this;
  516. }
  517. // Add methods to `MapCache`.
  518. MapCache.prototype.clear = mapCacheClear;
  519. MapCache.prototype['delete'] = mapCacheDelete;
  520. MapCache.prototype.get = mapCacheGet;
  521. MapCache.prototype.has = mapCacheHas;
  522. MapCache.prototype.set = mapCacheSet;
  523. /**
  524. *
  525. * Creates an array cache object to store unique values.
  526. *
  527. * @private
  528. * @constructor
  529. * @param {Array} [values] The values to cache.
  530. */
  531. function SetCache(values) {
  532. var index = -1,
  533. length = values ? values.length : 0;
  534. this.__data__ = new MapCache;
  535. while (++index < length) {
  536. this.add(values[index]);
  537. }
  538. }
  539. /**
  540. * Adds `value` to the array cache.
  541. *
  542. * @private
  543. * @name add
  544. * @memberOf SetCache
  545. * @alias push
  546. * @param {*} value The value to cache.
  547. * @returns {Object} Returns the cache instance.
  548. */
  549. function setCacheAdd(value) {
  550. this.__data__.set(value, HASH_UNDEFINED);
  551. return this;
  552. }
  553. /**
  554. * Checks if `value` is in the array cache.
  555. *
  556. * @private
  557. * @name has
  558. * @memberOf SetCache
  559. * @param {*} value The value to search for.
  560. * @returns {number} Returns `true` if `value` is found, else `false`.
  561. */
  562. function setCacheHas(value) {
  563. return this.__data__.has(value);
  564. }
  565. // Add methods to `SetCache`.
  566. SetCache.prototype.add = SetCache.prototype.push = setCacheAdd;
  567. SetCache.prototype.has = setCacheHas;
  568. /**
  569. * Gets the index at which the `key` is found in `array` of key-value pairs.
  570. *
  571. * @private
  572. * @param {Array} array The array to inspect.
  573. * @param {*} key The key to search for.
  574. * @returns {number} Returns the index of the matched value, else `-1`.
  575. */
  576. function assocIndexOf(array, key) {
  577. var length = array.length;
  578. while (length--) {
  579. if (eq(array[length][0], key)) {
  580. return length;
  581. }
  582. }
  583. return -1;
  584. }
  585. /**
  586. * The base implementation of `_.flatten` with support for restricting flattening.
  587. *
  588. * @private
  589. * @param {Array} array The array to flatten.
  590. * @param {number} depth The maximum recursion depth.
  591. * @param {boolean} [predicate=isFlattenable] The function invoked per iteration.
  592. * @param {boolean} [isStrict] Restrict to values that pass `predicate` checks.
  593. * @param {Array} [result=[]] The initial result value.
  594. * @returns {Array} Returns the new flattened array.
  595. */
  596. function baseFlatten(array, depth, predicate, isStrict, result) {
  597. var index = -1,
  598. length = array.length;
  599. predicate || (predicate = isFlattenable);
  600. result || (result = []);
  601. while (++index < length) {
  602. var value = array[index];
  603. if (depth > 0 && predicate(value)) {
  604. if (depth > 1) {
  605. // Recursively flatten arrays (susceptible to call stack limits).
  606. baseFlatten(value, depth - 1, predicate, isStrict, result);
  607. } else {
  608. arrayPush(result, value);
  609. }
  610. } else if (!isStrict) {
  611. result[result.length] = value;
  612. }
  613. }
  614. return result;
  615. }
  616. /**
  617. * The base implementation of `_.isNative` without bad shim checks.
  618. *
  619. * @private
  620. * @param {*} value The value to check.
  621. * @returns {boolean} Returns `true` if `value` is a native function,
  622. * else `false`.
  623. */
  624. function baseIsNative(value) {
  625. if (!isObject(value) || isMasked(value)) {
  626. return false;
  627. }
  628. var pattern = (isFunction(value) || isHostObject(value)) ? reIsNative : reIsHostCtor;
  629. return pattern.test(toSource(value));
  630. }
  631. /**
  632. * The base implementation of `_.rest` which doesn't validate or coerce arguments.
  633. *
  634. * @private
  635. * @param {Function} func The function to apply a rest parameter to.
  636. * @param {number} [start=func.length-1] The start position of the rest parameter.
  637. * @returns {Function} Returns the new function.
  638. */
  639. function baseRest(func, start) {
  640. start = nativeMax(start === undefined ? (func.length - 1) : start, 0);
  641. return function() {
  642. var args = arguments,
  643. index = -1,
  644. length = nativeMax(args.length - start, 0),
  645. array = Array(length);
  646. while (++index < length) {
  647. array[index] = args[start + index];
  648. }
  649. index = -1;
  650. var otherArgs = Array(start + 1);
  651. while (++index < start) {
  652. otherArgs[index] = args[index];
  653. }
  654. otherArgs[start] = array;
  655. return apply(func, this, otherArgs);
  656. };
  657. }
  658. /**
  659. * The base implementation of `_.uniqBy` without support for iteratee shorthands.
  660. *
  661. * @private
  662. * @param {Array} array The array to inspect.
  663. * @param {Function} [iteratee] The iteratee invoked per element.
  664. * @param {Function} [comparator] The comparator invoked per element.
  665. * @returns {Array} Returns the new duplicate free array.
  666. */
  667. function baseUniq(array, iteratee, comparator) {
  668. var index = -1,
  669. includes = arrayIncludes,
  670. length = array.length,
  671. isCommon = true,
  672. result = [],
  673. seen = result;
  674. if (comparator) {
  675. isCommon = false;
  676. includes = arrayIncludesWith;
  677. }
  678. else if (length >= LARGE_ARRAY_SIZE) {
  679. var set = iteratee ? null : createSet(array);
  680. if (set) {
  681. return setToArray(set);
  682. }
  683. isCommon = false;
  684. includes = cacheHas;
  685. seen = new SetCache;
  686. }
  687. else {
  688. seen = iteratee ? [] : result;
  689. }
  690. outer:
  691. while (++index < length) {
  692. var value = array[index],
  693. computed = iteratee ? iteratee(value) : value;
  694. value = (comparator || value !== 0) ? value : 0;
  695. if (isCommon && computed === computed) {
  696. var seenIndex = seen.length;
  697. while (seenIndex--) {
  698. if (seen[seenIndex] === computed) {
  699. continue outer;
  700. }
  701. }
  702. if (iteratee) {
  703. seen.push(computed);
  704. }
  705. result.push(value);
  706. }
  707. else if (!includes(seen, computed, comparator)) {
  708. if (seen !== result) {
  709. seen.push(computed);
  710. }
  711. result.push(value);
  712. }
  713. }
  714. return result;
  715. }
  716. /**
  717. * Creates a set object of `values`.
  718. *
  719. * @private
  720. * @param {Array} values The values to add to the set.
  721. * @returns {Object} Returns the new set.
  722. */
  723. var createSet = !(Set && (1 / setToArray(new Set([,-0]))[1]) == INFINITY) ? noop : function(values) {
  724. return new Set(values);
  725. };
  726. /**
  727. * Gets the data for `map`.
  728. *
  729. * @private
  730. * @param {Object} map The map to query.
  731. * @param {string} key The reference key.
  732. * @returns {*} Returns the map data.
  733. */
  734. function getMapData(map, key) {
  735. var data = map.__data__;
  736. return isKeyable(key)
  737. ? data[typeof key == 'string' ? 'string' : 'hash']
  738. : data.map;
  739. }
  740. /**
  741. * Gets the native function at `key` of `object`.
  742. *
  743. * @private
  744. * @param {Object} object The object to query.
  745. * @param {string} key The key of the method to get.
  746. * @returns {*} Returns the function if it's native, else `undefined`.
  747. */
  748. function getNative(object, key) {
  749. var value = getValue(object, key);
  750. return baseIsNative(value) ? value : undefined;
  751. }
  752. /**
  753. * Checks if `value` is a flattenable `arguments` object or array.
  754. *
  755. * @private
  756. * @param {*} value The value to check.
  757. * @returns {boolean} Returns `true` if `value` is flattenable, else `false`.
  758. */
  759. function isFlattenable(value) {
  760. return isArray(value) || isArguments(value) ||
  761. !!(spreadableSymbol && value && value[spreadableSymbol]);
  762. }
  763. /**
  764. * Checks if `value` is suitable for use as unique object key.
  765. *
  766. * @private
  767. * @param {*} value The value to check.
  768. * @returns {boolean} Returns `true` if `value` is suitable, else `false`.
  769. */
  770. function isKeyable(value) {
  771. var type = typeof value;
  772. return (type == 'string' || type == 'number' || type == 'symbol' || type == 'boolean')
  773. ? (value !== '__proto__')
  774. : (value === null);
  775. }
  776. /**
  777. * Checks if `func` has its source masked.
  778. *
  779. * @private
  780. * @param {Function} func The function to check.
  781. * @returns {boolean} Returns `true` if `func` is masked, else `false`.
  782. */
  783. function isMasked(func) {
  784. return !!maskSrcKey && (maskSrcKey in func);
  785. }
  786. /**
  787. * Converts `func` to its source code.
  788. *
  789. * @private
  790. * @param {Function} func The function to process.
  791. * @returns {string} Returns the source code.
  792. */
  793. function toSource(func) {
  794. if (func != null) {
  795. try {
  796. return funcToString.call(func);
  797. } catch (e) {}
  798. try {
  799. return (func + '');
  800. } catch (e) {}
  801. }
  802. return '';
  803. }
  804. /**
  805. * Creates an array of unique values, in order, from all given arrays using
  806. * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
  807. * for equality comparisons.
  808. *
  809. * @static
  810. * @memberOf _
  811. * @since 0.1.0
  812. * @category Array
  813. * @param {...Array} [arrays] The arrays to inspect.
  814. * @returns {Array} Returns the new array of combined values.
  815. * @example
  816. *
  817. * _.union([2], [1, 2]);
  818. * // => [2, 1]
  819. */
  820. var union = baseRest(function(arrays) {
  821. return baseUniq(baseFlatten(arrays, 1, isArrayLikeObject, true));
  822. });
  823. /**
  824. * Performs a
  825. * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
  826. * comparison between two values to determine if they are equivalent.
  827. *
  828. * @static
  829. * @memberOf _
  830. * @since 4.0.0
  831. * @category Lang
  832. * @param {*} value The value to compare.
  833. * @param {*} other The other value to compare.
  834. * @returns {boolean} Returns `true` if the values are equivalent, else `false`.
  835. * @example
  836. *
  837. * var object = { 'a': 1 };
  838. * var other = { 'a': 1 };
  839. *
  840. * _.eq(object, object);
  841. * // => true
  842. *
  843. * _.eq(object, other);
  844. * // => false
  845. *
  846. * _.eq('a', 'a');
  847. * // => true
  848. *
  849. * _.eq('a', Object('a'));
  850. * // => false
  851. *
  852. * _.eq(NaN, NaN);
  853. * // => true
  854. */
  855. function eq(value, other) {
  856. return value === other || (value !== value && other !== other);
  857. }
  858. /**
  859. * Checks if `value` is likely an `arguments` object.
  860. *
  861. * @static
  862. * @memberOf _
  863. * @since 0.1.0
  864. * @category Lang
  865. * @param {*} value The value to check.
  866. * @returns {boolean} Returns `true` if `value` is an `arguments` object,
  867. * else `false`.
  868. * @example
  869. *
  870. * _.isArguments(function() { return arguments; }());
  871. * // => true
  872. *
  873. * _.isArguments([1, 2, 3]);
  874. * // => false
  875. */
  876. function isArguments(value) {
  877. // Safari 8.1 makes `arguments.callee` enumerable in strict mode.
  878. return isArrayLikeObject(value) && hasOwnProperty.call(value, 'callee') &&
  879. (!propertyIsEnumerable.call(value, 'callee') || objectToString.call(value) == argsTag);
  880. }
  881. /**
  882. * Checks if `value` is classified as an `Array` object.
  883. *
  884. * @static
  885. * @memberOf _
  886. * @since 0.1.0
  887. * @category Lang
  888. * @param {*} value The value to check.
  889. * @returns {boolean} Returns `true` if `value` is an array, else `false`.
  890. * @example
  891. *
  892. * _.isArray([1, 2, 3]);
  893. * // => true
  894. *
  895. * _.isArray(document.body.children);
  896. * // => false
  897. *
  898. * _.isArray('abc');
  899. * // => false
  900. *
  901. * _.isArray(_.noop);
  902. * // => false
  903. */
  904. var isArray = Array.isArray;
  905. /**
  906. * Checks if `value` is array-like. A value is considered array-like if it's
  907. * not a function and has a `value.length` that's an integer greater than or
  908. * equal to `0` and less than or equal to `Number.MAX_SAFE_INTEGER`.
  909. *
  910. * @static
  911. * @memberOf _
  912. * @since 4.0.0
  913. * @category Lang
  914. * @param {*} value The value to check.
  915. * @returns {boolean} Returns `true` if `value` is array-like, else `false`.
  916. * @example
  917. *
  918. * _.isArrayLike([1, 2, 3]);
  919. * // => true
  920. *
  921. * _.isArrayLike(document.body.children);
  922. * // => true
  923. *
  924. * _.isArrayLike('abc');
  925. * // => true
  926. *
  927. * _.isArrayLike(_.noop);
  928. * // => false
  929. */
  930. function isArrayLike(value) {
  931. return value != null && isLength(value.length) && !isFunction(value);
  932. }
  933. /**
  934. * This method is like `_.isArrayLike` except that it also checks if `value`
  935. * is an object.
  936. *
  937. * @static
  938. * @memberOf _
  939. * @since 4.0.0
  940. * @category Lang
  941. * @param {*} value The value to check.
  942. * @returns {boolean} Returns `true` if `value` is an array-like object,
  943. * else `false`.
  944. * @example
  945. *
  946. * _.isArrayLikeObject([1, 2, 3]);
  947. * // => true
  948. *
  949. * _.isArrayLikeObject(document.body.children);
  950. * // => true
  951. *
  952. * _.isArrayLikeObject('abc');
  953. * // => false
  954. *
  955. * _.isArrayLikeObject(_.noop);
  956. * // => false
  957. */
  958. function isArrayLikeObject(value) {
  959. return isObjectLike(value) && isArrayLike(value);
  960. }
  961. /**
  962. * Checks if `value` is classified as a `Function` object.
  963. *
  964. * @static
  965. * @memberOf _
  966. * @since 0.1.0
  967. * @category Lang
  968. * @param {*} value The value to check.
  969. * @returns {boolean} Returns `true` if `value` is a function, else `false`.
  970. * @example
  971. *
  972. * _.isFunction(_);
  973. * // => true
  974. *
  975. * _.isFunction(/abc/);
  976. * // => false
  977. */
  978. function isFunction(value) {
  979. // The use of `Object#toString` avoids issues with the `typeof` operator
  980. // in Safari 8-9 which returns 'object' for typed array and other constructors.
  981. var tag = isObject(value) ? objectToString.call(value) : '';
  982. return tag == funcTag || tag == genTag;
  983. }
  984. /**
  985. * Checks if `value` is a valid array-like length.
  986. *
  987. * **Note:** This method is loosely based on
  988. * [`ToLength`](http://ecma-international.org/ecma-262/7.0/#sec-tolength).
  989. *
  990. * @static
  991. * @memberOf _
  992. * @since 4.0.0
  993. * @category Lang
  994. * @param {*} value The value to check.
  995. * @returns {boolean} Returns `true` if `value` is a valid length, else `false`.
  996. * @example
  997. *
  998. * _.isLength(3);
  999. * // => true
  1000. *
  1001. * _.isLength(Number.MIN_VALUE);
  1002. * // => false
  1003. *
  1004. * _.isLength(Infinity);
  1005. * // => false
  1006. *
  1007. * _.isLength('3');
  1008. * // => false
  1009. */
  1010. function isLength(value) {
  1011. return typeof value == 'number' &&
  1012. value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER;
  1013. }
  1014. /**
  1015. * Checks if `value` is the
  1016. * [language type](http://www.ecma-international.org/ecma-262/7.0/#sec-ecmascript-language-types)
  1017. * of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)
  1018. *
  1019. * @static
  1020. * @memberOf _
  1021. * @since 0.1.0
  1022. * @category Lang
  1023. * @param {*} value The value to check.
  1024. * @returns {boolean} Returns `true` if `value` is an object, else `false`.
  1025. * @example
  1026. *
  1027. * _.isObject({});
  1028. * // => true
  1029. *
  1030. * _.isObject([1, 2, 3]);
  1031. * // => true
  1032. *
  1033. * _.isObject(_.noop);
  1034. * // => true
  1035. *
  1036. * _.isObject(null);
  1037. * // => false
  1038. */
  1039. function isObject(value) {
  1040. var type = typeof value;
  1041. return !!value && (type == 'object' || type == 'function');
  1042. }
  1043. /**
  1044. * Checks if `value` is object-like. A value is object-like if it's not `null`
  1045. * and has a `typeof` result of "object".
  1046. *
  1047. * @static
  1048. * @memberOf _
  1049. * @since 4.0.0
  1050. * @category Lang
  1051. * @param {*} value The value to check.
  1052. * @returns {boolean} Returns `true` if `value` is object-like, else `false`.
  1053. * @example
  1054. *
  1055. * _.isObjectLike({});
  1056. * // => true
  1057. *
  1058. * _.isObjectLike([1, 2, 3]);
  1059. * // => true
  1060. *
  1061. * _.isObjectLike(_.noop);
  1062. * // => false
  1063. *
  1064. * _.isObjectLike(null);
  1065. * // => false
  1066. */
  1067. function isObjectLike(value) {
  1068. return !!value && typeof value == 'object';
  1069. }
  1070. /**
  1071. * This method returns `undefined`.
  1072. *
  1073. * @static
  1074. * @memberOf _
  1075. * @since 2.3.0
  1076. * @category Util
  1077. * @example
  1078. *
  1079. * _.times(2, _.noop);
  1080. * // => [undefined, undefined]
  1081. */
  1082. function noop() {
  1083. // No operation performed.
  1084. }
  1085. module.exports = union;