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.

isNodesEquivalent.js 1.4KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", {
  3. value: true
  4. });
  5. exports.default = isNodesEquivalent;
  6. var _definitions = require("../definitions");
  7. function isNodesEquivalent(a, b) {
  8. if (typeof a !== "object" || typeof b !== "object" || a == null || b == null) {
  9. return a === b;
  10. }
  11. if (a.type !== b.type) {
  12. return false;
  13. }
  14. const fields = Object.keys(_definitions.NODE_FIELDS[a.type] || a.type);
  15. const visitorKeys = _definitions.VISITOR_KEYS[a.type];
  16. for (const field of fields) {
  17. if (typeof a[field] !== typeof b[field]) {
  18. return false;
  19. }
  20. if (a[field] == null && b[field] == null) {
  21. continue;
  22. } else if (a[field] == null || b[field] == null) {
  23. return false;
  24. }
  25. if (Array.isArray(a[field])) {
  26. if (!Array.isArray(b[field])) {
  27. return false;
  28. }
  29. if (a[field].length !== b[field].length) {
  30. return false;
  31. }
  32. for (let i = 0; i < a[field].length; i++) {
  33. if (!isNodesEquivalent(a[field][i], b[field][i])) {
  34. return false;
  35. }
  36. }
  37. continue;
  38. }
  39. if (typeof a[field] === "object" && !(visitorKeys != null && visitorKeys.includes(field))) {
  40. for (const key of Object.keys(a[field])) {
  41. if (a[field][key] !== b[field][key]) {
  42. return false;
  43. }
  44. }
  45. continue;
  46. }
  47. if (!isNodesEquivalent(a[field], b[field])) {
  48. return false;
  49. }
  50. }
  51. return true;
  52. }