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.

jasmineUtils.js 7.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279
  1. 'use strict';
  2. Object.defineProperty(exports, '__esModule', {
  3. value: true
  4. });
  5. exports.equals = equals;
  6. exports.isA = isA;
  7. exports.fnNameFor = fnNameFor;
  8. exports.isUndefined = isUndefined;
  9. exports.hasProperty = hasProperty;
  10. exports.isImmutableUnorderedKeyed = isImmutableUnorderedKeyed;
  11. exports.isImmutableUnorderedSet = isImmutableUnorderedSet;
  12. /*
  13. Copyright (c) 2008-2016 Pivotal Labs
  14. Permission is hereby granted, free of charge, to any person obtaining
  15. a copy of this software and associated documentation files (the
  16. "Software"), to deal in the Software without restriction, including
  17. without limitation the rights to use, copy, modify, merge, publish,
  18. distribute, sublicense, and/or sell copies of the Software, and to
  19. permit persons to whom the Software is furnished to do so, subject to
  20. the following conditions:
  21. The above copyright notice and this permission notice shall be
  22. included in all copies or substantial portions of the Software.
  23. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  24. EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  25. MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  26. NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
  27. LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
  28. OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
  29. WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  30. */
  31. /* eslint-disable */
  32. // Extracted out of jasmine 2.5.2
  33. function equals(a, b, customTesters, strictCheck) {
  34. customTesters = customTesters || [];
  35. return eq(a, b, [], [], customTesters, strictCheck ? hasKey : hasDefinedKey);
  36. }
  37. const functionToString = Function.prototype.toString;
  38. function isAsymmetric(obj) {
  39. return !!obj && isA('Function', obj.asymmetricMatch);
  40. }
  41. function asymmetricMatch(a, b) {
  42. var asymmetricA = isAsymmetric(a),
  43. asymmetricB = isAsymmetric(b);
  44. if (asymmetricA && asymmetricB) {
  45. return undefined;
  46. }
  47. if (asymmetricA) {
  48. return a.asymmetricMatch(b);
  49. }
  50. if (asymmetricB) {
  51. return b.asymmetricMatch(a);
  52. }
  53. } // Equality function lovingly adapted from isEqual in
  54. // [Underscore](http://underscorejs.org)
  55. function eq(a, b, aStack, bStack, customTesters, hasKey) {
  56. var result = true;
  57. var asymmetricResult = asymmetricMatch(a, b);
  58. if (asymmetricResult !== undefined) {
  59. return asymmetricResult;
  60. }
  61. for (var i = 0; i < customTesters.length; i++) {
  62. var customTesterResult = customTesters[i](a, b);
  63. if (customTesterResult !== undefined) {
  64. return customTesterResult;
  65. }
  66. }
  67. if (a instanceof Error && b instanceof Error) {
  68. return a.message == b.message;
  69. }
  70. if (Object.is(a, b)) {
  71. return true;
  72. } // A strict comparison is necessary because `null == undefined`.
  73. if (a === null || b === null) {
  74. return a === b;
  75. }
  76. var className = Object.prototype.toString.call(a);
  77. if (className != Object.prototype.toString.call(b)) {
  78. return false;
  79. }
  80. switch (className) {
  81. case '[object Boolean]':
  82. case '[object String]':
  83. case '[object Number]':
  84. if (typeof a !== typeof b) {
  85. // One is a primitive, one a `new Primitive()`
  86. return false;
  87. } else if (typeof a !== 'object' && typeof b !== 'object') {
  88. // both are proper primitives
  89. return Object.is(a, b);
  90. } else {
  91. // both are `new Primitive()`s
  92. return Object.is(a.valueOf(), b.valueOf());
  93. }
  94. case '[object Date]':
  95. // Coerce dates to numeric primitive values. Dates are compared by their
  96. // millisecond representations. Note that invalid dates with millisecond representations
  97. // of `NaN` are not equivalent.
  98. return +a == +b;
  99. // RegExps are compared by their source patterns and flags.
  100. case '[object RegExp]':
  101. return a.source === b.source && a.flags === b.flags;
  102. }
  103. if (typeof a !== 'object' || typeof b !== 'object') {
  104. return false;
  105. } // Use DOM3 method isEqualNode (IE>=9)
  106. if (isDomNode(a) && isDomNode(b)) {
  107. return a.isEqualNode(b);
  108. } // Used to detect circular references.
  109. var length = aStack.length;
  110. while (length--) {
  111. // Linear search. Performance is inversely proportional to the number of
  112. // unique nested structures.
  113. // circular references at same depth are equal
  114. // circular reference is not equal to non-circular one
  115. if (aStack[length] === a) {
  116. return bStack[length] === b;
  117. } else if (bStack[length] === b) {
  118. return false;
  119. }
  120. } // Add the first object to the stack of traversed objects.
  121. aStack.push(a);
  122. bStack.push(b); // Recursively compare objects and arrays.
  123. // Compare array lengths to determine if a deep comparison is necessary.
  124. if (className == '[object Array]' && a.length !== b.length) {
  125. return false;
  126. } // Deep compare objects.
  127. var aKeys = keys(a, hasKey),
  128. key;
  129. var size = aKeys.length; // Ensure that both objects contain the same number of properties before comparing deep equality.
  130. if (keys(b, hasKey).length !== size) {
  131. return false;
  132. }
  133. while (size--) {
  134. key = aKeys[size]; // Deep compare each member
  135. result =
  136. hasKey(b, key) &&
  137. eq(a[key], b[key], aStack, bStack, customTesters, hasKey);
  138. if (!result) {
  139. return false;
  140. }
  141. } // Remove the first object from the stack of traversed objects.
  142. aStack.pop();
  143. bStack.pop();
  144. return result;
  145. }
  146. function keys(obj, hasKey) {
  147. var keys = [];
  148. for (var key in obj) {
  149. if (hasKey(obj, key)) {
  150. keys.push(key);
  151. }
  152. }
  153. return keys.concat(
  154. Object.getOwnPropertySymbols(obj).filter(
  155. symbol => Object.getOwnPropertyDescriptor(obj, symbol).enumerable
  156. )
  157. );
  158. }
  159. function hasDefinedKey(obj, key) {
  160. return hasKey(obj, key) && obj[key] !== undefined;
  161. }
  162. function hasKey(obj, key) {
  163. return Object.prototype.hasOwnProperty.call(obj, key);
  164. }
  165. function isA(typeName, value) {
  166. return Object.prototype.toString.apply(value) === '[object ' + typeName + ']';
  167. }
  168. function isDomNode(obj) {
  169. return (
  170. obj !== null &&
  171. typeof obj === 'object' &&
  172. typeof obj.nodeType === 'number' &&
  173. typeof obj.nodeName === 'string' &&
  174. typeof obj.isEqualNode === 'function'
  175. );
  176. }
  177. function fnNameFor(func) {
  178. if (func.name) {
  179. return func.name;
  180. }
  181. const matches = functionToString
  182. .call(func)
  183. .match(/^(?:async)?\s*function\s*\*?\s*([\w$]+)\s*\(/);
  184. return matches ? matches[1] : '<anonymous>';
  185. }
  186. function isUndefined(obj) {
  187. return obj === void 0;
  188. }
  189. function getPrototype(obj) {
  190. if (Object.getPrototypeOf) {
  191. return Object.getPrototypeOf(obj);
  192. }
  193. if (obj.constructor.prototype == obj) {
  194. return null;
  195. }
  196. return obj.constructor.prototype;
  197. }
  198. function hasProperty(obj, property) {
  199. if (!obj) {
  200. return false;
  201. }
  202. if (Object.prototype.hasOwnProperty.call(obj, property)) {
  203. return true;
  204. }
  205. return hasProperty(getPrototype(obj), property);
  206. } // SENTINEL constants are from https://github.com/facebook/immutable-js
  207. const IS_KEYED_SENTINEL = '@@__IMMUTABLE_KEYED__@@';
  208. const IS_SET_SENTINEL = '@@__IMMUTABLE_SET__@@';
  209. const IS_ORDERED_SENTINEL = '@@__IMMUTABLE_ORDERED__@@';
  210. function isImmutableUnorderedKeyed(maybeKeyed) {
  211. return !!(
  212. maybeKeyed &&
  213. maybeKeyed[IS_KEYED_SENTINEL] &&
  214. !maybeKeyed[IS_ORDERED_SENTINEL]
  215. );
  216. }
  217. function isImmutableUnorderedSet(maybeSet) {
  218. return !!(
  219. maybeSet &&
  220. maybeSet[IS_SET_SENTINEL] &&
  221. !maybeSet[IS_ORDERED_SENTINEL]
  222. );
  223. }