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.

match-object.js 1.6KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. "use strict";
  2. var every = require("@sinonjs/commons").prototypes.array.every;
  3. var concat = require("@sinonjs/commons").prototypes.array.concat;
  4. var typeOf = require("@sinonjs/commons").typeOf;
  5. var deepEqualFactory = require("../deep-equal").use;
  6. var isMatcher = require("./is-matcher");
  7. var keys = Object.keys;
  8. var getOwnPropertySymbols = Object.getOwnPropertySymbols;
  9. /**
  10. * Matches `actual` with `expectation`
  11. *
  12. * @private
  13. * @param {*} actual A value to examine
  14. * @param {object} expectation An object with properties to match on
  15. * @param {object} matcher A matcher to use for comparison
  16. * @returns {boolean} Returns true when `actual` matches all properties in `expectation`
  17. */
  18. function matchObject(actual, expectation, matcher) {
  19. var deepEqual = deepEqualFactory(matcher);
  20. if (actual === null || actual === undefined) {
  21. return false;
  22. }
  23. var expectedKeys = keys(expectation);
  24. /* istanbul ignore else: cannot collect coverage for engine that doesn't support Symbol */
  25. if (typeOf(getOwnPropertySymbols) === "function") {
  26. expectedKeys = concat(expectedKeys, getOwnPropertySymbols(expectation));
  27. }
  28. return every(expectedKeys, function (key) {
  29. var exp = expectation[key];
  30. var act = actual[key];
  31. if (isMatcher(exp)) {
  32. if (!exp.test(act)) {
  33. return false;
  34. }
  35. } else if (typeOf(exp) === "object") {
  36. if (!matchObject(act, exp, matcher)) {
  37. return false;
  38. }
  39. } else if (!deepEqual(act, exp)) {
  40. return false;
  41. }
  42. return true;
  43. });
  44. }
  45. module.exports = matchObject;