mergeDeviceParams.js 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. "use strict";
  2. var __values = (this && this.__values) || function(o) {
  3. var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
  4. if (m) return m.call(o);
  5. if (o && typeof o.length === "number") return {
  6. next: function () {
  7. if (o && i >= o.length) o = void 0;
  8. return { value: o && o[i++], done: !o };
  9. }
  10. };
  11. throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
  12. };
  13. var __importDefault = (this && this.__importDefault) || function (mod) {
  14. return (mod && mod.__esModule) ? mod : { "default": mod };
  15. };
  16. Object.defineProperty(exports, "__esModule", { value: true });
  17. exports.assignDeviceParams = void 0;
  18. var lodash_1 = __importDefault(require("lodash"));
  19. exports.default = (function (source, params) {
  20. return lodash_1.default.mergeWith(source, params, function (objVal, srcVal, key) {
  21. var e_1, _a;
  22. if (key === 'rfList') {
  23. return srcVal;
  24. }
  25. if (key.includes('lightScenes')) {
  26. return srcVal;
  27. }
  28. if (key === 'locks') {
  29. return srcVal;
  30. }
  31. if (Array.isArray(objVal) && Array.isArray(srcVal)) {
  32. try {
  33. for (var srcVal_1 = __values(srcVal), srcVal_1_1 = srcVal_1.next(); !srcVal_1_1.done; srcVal_1_1 = srcVal_1.next()) {
  34. var item = srcVal_1_1.value;
  35. if (item.outlet !== undefined) {
  36. objVal[item.outlet] = item;
  37. }
  38. }
  39. }
  40. catch (e_1_1) { e_1 = { error: e_1_1 }; }
  41. finally {
  42. try {
  43. if (srcVal_1_1 && !srcVal_1_1.done && (_a = srcVal_1.return)) _a.call(srcVal_1);
  44. }
  45. finally { if (e_1) throw e_1.error; }
  46. }
  47. return objVal;
  48. }
  49. return srcVal;
  50. });
  51. });
  52. function assignDeviceParams(object, source) {
  53. return lodash_1.default.assign(object, source);
  54. }
  55. exports.assignDeviceParams = assignDeviceParams;