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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350
  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 INFINITY = 1 / 0,
  11. MAX_SAFE_INTEGER = 9007199254740991;
  12. /** `Object#toString` result references. */
  13. var argsTag = '[object Arguments]',
  14. funcTag = '[object Function]',
  15. genTag = '[object GeneratorFunction]';
  16. /** Detect free variable `global` from Node.js. */
  17. var freeGlobal = typeof global == 'object' && global && global.Object === Object && global;
  18. /** Detect free variable `self`. */
  19. var freeSelf = typeof self == 'object' && self && self.Object === Object && self;
  20. /** Used as a reference to the global object. */
  21. var root = freeGlobal || freeSelf || Function('return this')();
  22. /**
  23. * Appends the elements of `values` to `array`.
  24. *
  25. * @private
  26. * @param {Array} array The array to modify.
  27. * @param {Array} values The values to append.
  28. * @returns {Array} Returns `array`.
  29. */
  30. function arrayPush(array, values) {
  31. var index = -1,
  32. length = values.length,
  33. offset = array.length;
  34. while (++index < length) {
  35. array[offset + index] = values[index];
  36. }
  37. return array;
  38. }
  39. /** Used for built-in method references. */
  40. var objectProto = Object.prototype;
  41. /** Used to check objects for own properties. */
  42. var hasOwnProperty = objectProto.hasOwnProperty;
  43. /**
  44. * Used to resolve the
  45. * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
  46. * of values.
  47. */
  48. var objectToString = objectProto.toString;
  49. /** Built-in value references. */
  50. var Symbol = root.Symbol,
  51. propertyIsEnumerable = objectProto.propertyIsEnumerable,
  52. spreadableSymbol = Symbol ? Symbol.isConcatSpreadable : undefined;
  53. /**
  54. * The base implementation of `_.flatten` with support for restricting flattening.
  55. *
  56. * @private
  57. * @param {Array} array The array to flatten.
  58. * @param {number} depth The maximum recursion depth.
  59. * @param {boolean} [predicate=isFlattenable] The function invoked per iteration.
  60. * @param {boolean} [isStrict] Restrict to values that pass `predicate` checks.
  61. * @param {Array} [result=[]] The initial result value.
  62. * @returns {Array} Returns the new flattened array.
  63. */
  64. function baseFlatten(array, depth, predicate, isStrict, result) {
  65. var index = -1,
  66. length = array.length;
  67. predicate || (predicate = isFlattenable);
  68. result || (result = []);
  69. while (++index < length) {
  70. var value = array[index];
  71. if (depth > 0 && predicate(value)) {
  72. if (depth > 1) {
  73. // Recursively flatten arrays (susceptible to call stack limits).
  74. baseFlatten(value, depth - 1, predicate, isStrict, result);
  75. } else {
  76. arrayPush(result, value);
  77. }
  78. } else if (!isStrict) {
  79. result[result.length] = value;
  80. }
  81. }
  82. return result;
  83. }
  84. /**
  85. * Checks if `value` is a flattenable `arguments` object or array.
  86. *
  87. * @private
  88. * @param {*} value The value to check.
  89. * @returns {boolean} Returns `true` if `value` is flattenable, else `false`.
  90. */
  91. function isFlattenable(value) {
  92. return isArray(value) || isArguments(value) ||
  93. !!(spreadableSymbol && value && value[spreadableSymbol]);
  94. }
  95. /**
  96. * Recursively flattens `array`.
  97. *
  98. * @static
  99. * @memberOf _
  100. * @since 3.0.0
  101. * @category Array
  102. * @param {Array} array The array to flatten.
  103. * @returns {Array} Returns the new flattened array.
  104. * @example
  105. *
  106. * _.flattenDeep([1, [2, [3, [4]], 5]]);
  107. * // => [1, 2, 3, 4, 5]
  108. */
  109. function flattenDeep(array) {
  110. var length = array ? array.length : 0;
  111. return length ? baseFlatten(array, INFINITY) : [];
  112. }
  113. /**
  114. * Checks if `value` is likely an `arguments` object.
  115. *
  116. * @static
  117. * @memberOf _
  118. * @since 0.1.0
  119. * @category Lang
  120. * @param {*} value The value to check.
  121. * @returns {boolean} Returns `true` if `value` is an `arguments` object,
  122. * else `false`.
  123. * @example
  124. *
  125. * _.isArguments(function() { return arguments; }());
  126. * // => true
  127. *
  128. * _.isArguments([1, 2, 3]);
  129. * // => false
  130. */
  131. function isArguments(value) {
  132. // Safari 8.1 makes `arguments.callee` enumerable in strict mode.
  133. return isArrayLikeObject(value) && hasOwnProperty.call(value, 'callee') &&
  134. (!propertyIsEnumerable.call(value, 'callee') || objectToString.call(value) == argsTag);
  135. }
  136. /**
  137. * Checks if `value` is classified as an `Array` object.
  138. *
  139. * @static
  140. * @memberOf _
  141. * @since 0.1.0
  142. * @category Lang
  143. * @param {*} value The value to check.
  144. * @returns {boolean} Returns `true` if `value` is an array, else `false`.
  145. * @example
  146. *
  147. * _.isArray([1, 2, 3]);
  148. * // => true
  149. *
  150. * _.isArray(document.body.children);
  151. * // => false
  152. *
  153. * _.isArray('abc');
  154. * // => false
  155. *
  156. * _.isArray(_.noop);
  157. * // => false
  158. */
  159. var isArray = Array.isArray;
  160. /**
  161. * Checks if `value` is array-like. A value is considered array-like if it's
  162. * not a function and has a `value.length` that's an integer greater than or
  163. * equal to `0` and less than or equal to `Number.MAX_SAFE_INTEGER`.
  164. *
  165. * @static
  166. * @memberOf _
  167. * @since 4.0.0
  168. * @category Lang
  169. * @param {*} value The value to check.
  170. * @returns {boolean} Returns `true` if `value` is array-like, else `false`.
  171. * @example
  172. *
  173. * _.isArrayLike([1, 2, 3]);
  174. * // => true
  175. *
  176. * _.isArrayLike(document.body.children);
  177. * // => true
  178. *
  179. * _.isArrayLike('abc');
  180. * // => true
  181. *
  182. * _.isArrayLike(_.noop);
  183. * // => false
  184. */
  185. function isArrayLike(value) {
  186. return value != null && isLength(value.length) && !isFunction(value);
  187. }
  188. /**
  189. * This method is like `_.isArrayLike` except that it also checks if `value`
  190. * is an object.
  191. *
  192. * @static
  193. * @memberOf _
  194. * @since 4.0.0
  195. * @category Lang
  196. * @param {*} value The value to check.
  197. * @returns {boolean} Returns `true` if `value` is an array-like object,
  198. * else `false`.
  199. * @example
  200. *
  201. * _.isArrayLikeObject([1, 2, 3]);
  202. * // => true
  203. *
  204. * _.isArrayLikeObject(document.body.children);
  205. * // => true
  206. *
  207. * _.isArrayLikeObject('abc');
  208. * // => false
  209. *
  210. * _.isArrayLikeObject(_.noop);
  211. * // => false
  212. */
  213. function isArrayLikeObject(value) {
  214. return isObjectLike(value) && isArrayLike(value);
  215. }
  216. /**
  217. * Checks if `value` is classified as a `Function` object.
  218. *
  219. * @static
  220. * @memberOf _
  221. * @since 0.1.0
  222. * @category Lang
  223. * @param {*} value The value to check.
  224. * @returns {boolean} Returns `true` if `value` is a function, else `false`.
  225. * @example
  226. *
  227. * _.isFunction(_);
  228. * // => true
  229. *
  230. * _.isFunction(/abc/);
  231. * // => false
  232. */
  233. function isFunction(value) {
  234. // The use of `Object#toString` avoids issues with the `typeof` operator
  235. // in Safari 8-9 which returns 'object' for typed array and other constructors.
  236. var tag = isObject(value) ? objectToString.call(value) : '';
  237. return tag == funcTag || tag == genTag;
  238. }
  239. /**
  240. * Checks if `value` is a valid array-like length.
  241. *
  242. * **Note:** This method is loosely based on
  243. * [`ToLength`](http://ecma-international.org/ecma-262/7.0/#sec-tolength).
  244. *
  245. * @static
  246. * @memberOf _
  247. * @since 4.0.0
  248. * @category Lang
  249. * @param {*} value The value to check.
  250. * @returns {boolean} Returns `true` if `value` is a valid length, else `false`.
  251. * @example
  252. *
  253. * _.isLength(3);
  254. * // => true
  255. *
  256. * _.isLength(Number.MIN_VALUE);
  257. * // => false
  258. *
  259. * _.isLength(Infinity);
  260. * // => false
  261. *
  262. * _.isLength('3');
  263. * // => false
  264. */
  265. function isLength(value) {
  266. return typeof value == 'number' &&
  267. value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER;
  268. }
  269. /**
  270. * Checks if `value` is the
  271. * [language type](http://www.ecma-international.org/ecma-262/7.0/#sec-ecmascript-language-types)
  272. * of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)
  273. *
  274. * @static
  275. * @memberOf _
  276. * @since 0.1.0
  277. * @category Lang
  278. * @param {*} value The value to check.
  279. * @returns {boolean} Returns `true` if `value` is an object, else `false`.
  280. * @example
  281. *
  282. * _.isObject({});
  283. * // => true
  284. *
  285. * _.isObject([1, 2, 3]);
  286. * // => true
  287. *
  288. * _.isObject(_.noop);
  289. * // => true
  290. *
  291. * _.isObject(null);
  292. * // => false
  293. */
  294. function isObject(value) {
  295. var type = typeof value;
  296. return !!value && (type == 'object' || type == 'function');
  297. }
  298. /**
  299. * Checks if `value` is object-like. A value is object-like if it's not `null`
  300. * and has a `typeof` result of "object".
  301. *
  302. * @static
  303. * @memberOf _
  304. * @since 4.0.0
  305. * @category Lang
  306. * @param {*} value The value to check.
  307. * @returns {boolean} Returns `true` if `value` is object-like, else `false`.
  308. * @example
  309. *
  310. * _.isObjectLike({});
  311. * // => true
  312. *
  313. * _.isObjectLike([1, 2, 3]);
  314. * // => true
  315. *
  316. * _.isObjectLike(_.noop);
  317. * // => false
  318. *
  319. * _.isObjectLike(null);
  320. * // => false
  321. */
  322. function isObjectLike(value) {
  323. return !!value && typeof value == 'object';
  324. }
  325. module.exports = flattenDeep;