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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379
  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 references for various `Number` constants. */
  10. var MAX_SAFE_INTEGER = 9007199254740991;
  11. /** `Object#toString` result references. */
  12. var funcTag = '[object Function]',
  13. genTag = '[object GeneratorFunction]';
  14. /**
  15. * A faster alternative to `Function#apply`, this function invokes `func`
  16. * with the `this` binding of `thisArg` and the arguments of `args`.
  17. *
  18. * @private
  19. * @param {Function} func The function to invoke.
  20. * @param {*} thisArg The `this` binding of `func`.
  21. * @param {Array} args The arguments to invoke `func` with.
  22. * @returns {*} Returns the result of `func`.
  23. */
  24. function apply(func, thisArg, args) {
  25. switch (args.length) {
  26. case 0: return func.call(thisArg);
  27. case 1: return func.call(thisArg, args[0]);
  28. case 2: return func.call(thisArg, args[0], args[1]);
  29. case 3: return func.call(thisArg, args[0], args[1], args[2]);
  30. }
  31. return func.apply(thisArg, args);
  32. }
  33. /**
  34. * A specialized version of `_.filter` for arrays without support for
  35. * iteratee shorthands.
  36. *
  37. * @private
  38. * @param {Array} [array] The array to iterate over.
  39. * @param {Function} predicate The function invoked per iteration.
  40. * @returns {Array} Returns the new filtered array.
  41. */
  42. function arrayFilter(array, predicate) {
  43. var index = -1,
  44. length = array ? array.length : 0,
  45. resIndex = 0,
  46. result = [];
  47. while (++index < length) {
  48. var value = array[index];
  49. if (predicate(value, index, array)) {
  50. result[resIndex++] = value;
  51. }
  52. }
  53. return result;
  54. }
  55. /**
  56. * A specialized version of `_.map` for arrays without support for iteratee
  57. * shorthands.
  58. *
  59. * @private
  60. * @param {Array} [array] The array to iterate over.
  61. * @param {Function} iteratee The function invoked per iteration.
  62. * @returns {Array} Returns the new mapped array.
  63. */
  64. function arrayMap(array, iteratee) {
  65. var index = -1,
  66. length = array ? array.length : 0,
  67. result = Array(length);
  68. while (++index < length) {
  69. result[index] = iteratee(array[index], index, array);
  70. }
  71. return result;
  72. }
  73. /**
  74. * The base implementation of `_.property` without support for deep paths.
  75. *
  76. * @private
  77. * @param {string} key The key of the property to get.
  78. * @returns {Function} Returns the new accessor function.
  79. */
  80. function baseProperty(key) {
  81. return function(object) {
  82. return object == null ? undefined : object[key];
  83. };
  84. }
  85. /**
  86. * The base implementation of `_.times` without support for iteratee shorthands
  87. * or max array length checks.
  88. *
  89. * @private
  90. * @param {number} n The number of times to invoke `iteratee`.
  91. * @param {Function} iteratee The function invoked per iteration.
  92. * @returns {Array} Returns the array of results.
  93. */
  94. function baseTimes(n, iteratee) {
  95. var index = -1,
  96. result = Array(n);
  97. while (++index < n) {
  98. result[index] = iteratee(index);
  99. }
  100. return result;
  101. }
  102. /** Used for built-in method references. */
  103. var objectProto = Object.prototype;
  104. /**
  105. * Used to resolve the
  106. * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
  107. * of values.
  108. */
  109. var objectToString = objectProto.toString;
  110. /* Built-in method references for those with the same name as other `lodash` methods. */
  111. var nativeMax = Math.max;
  112. /**
  113. * The base implementation of `_.rest` which doesn't validate or coerce arguments.
  114. *
  115. * @private
  116. * @param {Function} func The function to apply a rest parameter to.
  117. * @param {number} [start=func.length-1] The start position of the rest parameter.
  118. * @returns {Function} Returns the new function.
  119. */
  120. function baseRest(func, start) {
  121. start = nativeMax(start === undefined ? (func.length - 1) : start, 0);
  122. return function() {
  123. var args = arguments,
  124. index = -1,
  125. length = nativeMax(args.length - start, 0),
  126. array = Array(length);
  127. while (++index < length) {
  128. array[index] = args[start + index];
  129. }
  130. index = -1;
  131. var otherArgs = Array(start + 1);
  132. while (++index < start) {
  133. otherArgs[index] = args[index];
  134. }
  135. otherArgs[start] = array;
  136. return apply(func, this, otherArgs);
  137. };
  138. }
  139. /**
  140. * This method is like `_.zip` except that it accepts an array of grouped
  141. * elements and creates an array regrouping the elements to their pre-zip
  142. * configuration.
  143. *
  144. * @static
  145. * @memberOf _
  146. * @since 1.2.0
  147. * @category Array
  148. * @param {Array} array The array of grouped elements to process.
  149. * @returns {Array} Returns the new array of regrouped elements.
  150. * @example
  151. *
  152. * var zipped = _.zip(['a', 'b'], [1, 2], [true, false]);
  153. * // => [['a', 1, true], ['b', 2, false]]
  154. *
  155. * _.unzip(zipped);
  156. * // => [['a', 'b'], [1, 2], [true, false]]
  157. */
  158. function unzip(array) {
  159. if (!(array && array.length)) {
  160. return [];
  161. }
  162. var length = 0;
  163. array = arrayFilter(array, function(group) {
  164. if (isArrayLikeObject(group)) {
  165. length = nativeMax(group.length, length);
  166. return true;
  167. }
  168. });
  169. return baseTimes(length, function(index) {
  170. return arrayMap(array, baseProperty(index));
  171. });
  172. }
  173. /**
  174. * Creates an array of grouped elements, the first of which contains the
  175. * first elements of the given arrays, the second of which contains the
  176. * second elements of the given arrays, and so on.
  177. *
  178. * @static
  179. * @memberOf _
  180. * @since 0.1.0
  181. * @category Array
  182. * @param {...Array} [arrays] The arrays to process.
  183. * @returns {Array} Returns the new array of grouped elements.
  184. * @example
  185. *
  186. * _.zip(['a', 'b'], [1, 2], [true, false]);
  187. * // => [['a', 1, true], ['b', 2, false]]
  188. */
  189. var zip = baseRest(unzip);
  190. /**
  191. * Checks if `value` is array-like. A value is considered array-like if it's
  192. * not a function and has a `value.length` that's an integer greater than or
  193. * equal to `0` and less than or equal to `Number.MAX_SAFE_INTEGER`.
  194. *
  195. * @static
  196. * @memberOf _
  197. * @since 4.0.0
  198. * @category Lang
  199. * @param {*} value The value to check.
  200. * @returns {boolean} Returns `true` if `value` is array-like, else `false`.
  201. * @example
  202. *
  203. * _.isArrayLike([1, 2, 3]);
  204. * // => true
  205. *
  206. * _.isArrayLike(document.body.children);
  207. * // => true
  208. *
  209. * _.isArrayLike('abc');
  210. * // => true
  211. *
  212. * _.isArrayLike(_.noop);
  213. * // => false
  214. */
  215. function isArrayLike(value) {
  216. return value != null && isLength(value.length) && !isFunction(value);
  217. }
  218. /**
  219. * This method is like `_.isArrayLike` except that it also checks if `value`
  220. * is an object.
  221. *
  222. * @static
  223. * @memberOf _
  224. * @since 4.0.0
  225. * @category Lang
  226. * @param {*} value The value to check.
  227. * @returns {boolean} Returns `true` if `value` is an array-like object,
  228. * else `false`.
  229. * @example
  230. *
  231. * _.isArrayLikeObject([1, 2, 3]);
  232. * // => true
  233. *
  234. * _.isArrayLikeObject(document.body.children);
  235. * // => true
  236. *
  237. * _.isArrayLikeObject('abc');
  238. * // => false
  239. *
  240. * _.isArrayLikeObject(_.noop);
  241. * // => false
  242. */
  243. function isArrayLikeObject(value) {
  244. return isObjectLike(value) && isArrayLike(value);
  245. }
  246. /**
  247. * Checks if `value` is classified as a `Function` object.
  248. *
  249. * @static
  250. * @memberOf _
  251. * @since 0.1.0
  252. * @category Lang
  253. * @param {*} value The value to check.
  254. * @returns {boolean} Returns `true` if `value` is a function, else `false`.
  255. * @example
  256. *
  257. * _.isFunction(_);
  258. * // => true
  259. *
  260. * _.isFunction(/abc/);
  261. * // => false
  262. */
  263. function isFunction(value) {
  264. // The use of `Object#toString` avoids issues with the `typeof` operator
  265. // in Safari 8-9 which returns 'object' for typed array and other constructors.
  266. var tag = isObject(value) ? objectToString.call(value) : '';
  267. return tag == funcTag || tag == genTag;
  268. }
  269. /**
  270. * Checks if `value` is a valid array-like length.
  271. *
  272. * **Note:** This method is loosely based on
  273. * [`ToLength`](http://ecma-international.org/ecma-262/7.0/#sec-tolength).
  274. *
  275. * @static
  276. * @memberOf _
  277. * @since 4.0.0
  278. * @category Lang
  279. * @param {*} value The value to check.
  280. * @returns {boolean} Returns `true` if `value` is a valid length, else `false`.
  281. * @example
  282. *
  283. * _.isLength(3);
  284. * // => true
  285. *
  286. * _.isLength(Number.MIN_VALUE);
  287. * // => false
  288. *
  289. * _.isLength(Infinity);
  290. * // => false
  291. *
  292. * _.isLength('3');
  293. * // => false
  294. */
  295. function isLength(value) {
  296. return typeof value == 'number' &&
  297. value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER;
  298. }
  299. /**
  300. * Checks if `value` is the
  301. * [language type](http://www.ecma-international.org/ecma-262/7.0/#sec-ecmascript-language-types)
  302. * of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)
  303. *
  304. * @static
  305. * @memberOf _
  306. * @since 0.1.0
  307. * @category Lang
  308. * @param {*} value The value to check.
  309. * @returns {boolean} Returns `true` if `value` is an object, else `false`.
  310. * @example
  311. *
  312. * _.isObject({});
  313. * // => true
  314. *
  315. * _.isObject([1, 2, 3]);
  316. * // => true
  317. *
  318. * _.isObject(_.noop);
  319. * // => true
  320. *
  321. * _.isObject(null);
  322. * // => false
  323. */
  324. function isObject(value) {
  325. var type = typeof value;
  326. return !!value && (type == 'object' || type == 'function');
  327. }
  328. /**
  329. * Checks if `value` is object-like. A value is object-like if it's not `null`
  330. * and has a `typeof` result of "object".
  331. *
  332. * @static
  333. * @memberOf _
  334. * @since 4.0.0
  335. * @category Lang
  336. * @param {*} value The value to check.
  337. * @returns {boolean} Returns `true` if `value` is object-like, else `false`.
  338. * @example
  339. *
  340. * _.isObjectLike({});
  341. * // => true
  342. *
  343. * _.isObjectLike([1, 2, 3]);
  344. * // => true
  345. *
  346. * _.isObjectLike(_.noop);
  347. * // => false
  348. *
  349. * _.isObjectLike(null);
  350. * // => false
  351. */
  352. function isObjectLike(value) {
  353. return !!value && typeof value == 'object';
  354. }
  355. module.exports = zip;