roboto-js 1.4.1 → 1.4.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -58,10 +58,23 @@ var RbtObject = exports["default"] = /*#__PURE__*/function () {
58
58
  }, {
59
59
  key: "set",
60
60
  value: function set(path, value) {
61
+ var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
61
62
  var currentValue = _lodash["default"].get(this._data, path);
62
- if (!_lodash["default"].isEqual(currentValue, value)) {
63
- _lodash["default"].set(this._data, path, value);
64
- this._addChange(path);
63
+
64
+ // Check if merge is required
65
+ if (options.merge) {
66
+ // Merge the value if merge option is true
67
+ var mergedValue = _lodash["default"].merge({}, currentValue, value);
68
+ if (!_lodash["default"].isEqual(currentValue, mergedValue)) {
69
+ _lodash["default"].set(this._data, path, mergedValue);
70
+ this._addChange(path);
71
+ }
72
+ } else {
73
+ // Set the value directly if no merge option or merge option is false
74
+ if (!_lodash["default"].isEqual(currentValue, value)) {
75
+ _lodash["default"].set(this._data, path, value);
76
+ this._addChange(path);
77
+ }
65
78
  }
66
79
  }
67
80
  }, {
@@ -86,17 +99,6 @@ var RbtObject = exports["default"] = /*#__PURE__*/function () {
86
99
  rpcMeta: this.rpcMeta
87
100
  });
88
101
  }
89
- }, {
90
- key: "serialize",
91
- value: function serialize() {
92
- return JSON.stringify(this.toRecord());
93
- }
94
- }, {
95
- key: "deserialize",
96
- value: function deserialize(strRecord) {
97
- var record = JSON.parse(strRecord);
98
- return new RbtObject(record, this._axios);
99
- }
100
102
  }, {
101
103
  key: "clone",
102
104
  value: function clone() {
@@ -30,11 +30,23 @@ export default class RbtObject {
30
30
  this.rpcMeta.changes.push(path);
31
31
  }
32
32
  }
33
- set(path, value) {
33
+ set(path, value, options = {}) {
34
34
  const currentValue = _.get(this._data, path);
35
- if (!_.isEqual(currentValue, value)) {
36
- _.set(this._data, path, value);
37
- this._addChange(path);
35
+
36
+ // Check if merge is required
37
+ if (options.merge) {
38
+ // Merge the value if merge option is true
39
+ const mergedValue = _.merge({}, currentValue, value);
40
+ if (!_.isEqual(currentValue, mergedValue)) {
41
+ _.set(this._data, path, mergedValue);
42
+ this._addChange(path);
43
+ }
44
+ } else {
45
+ // Set the value directly if no merge option or merge option is false
46
+ if (!_.isEqual(currentValue, value)) {
47
+ _.set(this._data, path, value);
48
+ this._addChange(path);
49
+ }
38
50
  }
39
51
  }
40
52
  setData(newData) {
@@ -55,13 +67,6 @@ export default class RbtObject {
55
67
  rpcMeta: this.rpcMeta
56
68
  };
57
69
  }
58
- serialize() {
59
- return JSON.stringify(this.toRecord());
60
- }
61
- deserialize(strRecord) {
62
- let record = JSON.parse(strRecord);
63
- return new RbtObject(record, this._axios);
64
- }
65
70
  clone() {
66
71
  // Create a deep copy of the current object's data
67
72
  const clonedData = _.cloneDeep(this._internalData);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "roboto-js",
3
- "version": "1.4.1",
3
+ "version": "1.4.3",
4
4
  "type": "module",
5
5
  "description": "",
6
6
  "main": "dist/cjs/index.cjs",
package/src/rbt_object.js CHANGED
@@ -38,11 +38,23 @@ export default class RbtObject {
38
38
  }
39
39
  }
40
40
 
41
- set(path, value) {
41
+ set(path, value, options = {}) {
42
42
  const currentValue = _.get(this._data, path);
43
- if (!_.isEqual(currentValue, value)) {
44
- _.set(this._data, path, value);
45
- this._addChange(path);
43
+
44
+ // Check if merge is required
45
+ if (options.merge) {
46
+ // Merge the value if merge option is true
47
+ const mergedValue = _.merge({}, currentValue, value);
48
+ if (!_.isEqual(currentValue, mergedValue)) {
49
+ _.set(this._data, path, mergedValue);
50
+ this._addChange(path);
51
+ }
52
+ } else {
53
+ // Set the value directly if no merge option or merge option is false
54
+ if (!_.isEqual(currentValue, value)) {
55
+ _.set(this._data, path, value);
56
+ this._addChange(path);
57
+ }
46
58
  }
47
59
  }
48
60
 
@@ -67,16 +79,6 @@ export default class RbtObject {
67
79
  };
68
80
  }
69
81
 
70
-
71
- serialize(){
72
- return JSON.stringify(this.toRecord());
73
- }
74
-
75
- deserialize(strRecord){
76
- let record = JSON.parse(strRecord);
77
- return new RbtObject(record, this._axios);
78
- }
79
-
80
82
  clone() {
81
83
  // Create a deep copy of the current object's data
82
84
  const clonedData = _.cloneDeep(this._internalData);