roboto-js 1.4.2 → 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.
- package/dist/cjs/rbt_object.cjs +16 -17
- package/dist/esm/rbt_object.js +16 -15
- package/package.json +1 -1
- package/src/rbt_object.js +16 -19
package/dist/cjs/rbt_object.cjs
CHANGED
|
@@ -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
|
-
|
|
63
|
-
|
|
64
|
-
|
|
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,20 +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(_objectSpread(_objectSpread({}, this._internalData), {}, {
|
|
93
|
-
dataJson: this._data,
|
|
94
|
-
rpcMeta: this.rpcMeta
|
|
95
|
-
}));
|
|
96
|
-
}
|
|
97
|
-
}, {
|
|
98
|
-
key: "deserialize",
|
|
99
|
-
value: function deserialize(strRecord) {
|
|
100
|
-
var record = JSON.parse(strRecord);
|
|
101
|
-
return new RbtObject(record, this._axios);
|
|
102
|
-
}
|
|
103
102
|
}, {
|
|
104
103
|
key: "clone",
|
|
105
104
|
value: function clone() {
|
package/dist/esm/rbt_object.js
CHANGED
|
@@ -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
|
-
|
|
36
|
-
|
|
37
|
-
|
|
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,17 +67,6 @@ export default class RbtObject {
|
|
|
55
67
|
rpcMeta: this.rpcMeta
|
|
56
68
|
};
|
|
57
69
|
}
|
|
58
|
-
serialize() {
|
|
59
|
-
return JSON.stringify({
|
|
60
|
-
...this._internalData,
|
|
61
|
-
dataJson: this._data,
|
|
62
|
-
rpcMeta: this.rpcMeta
|
|
63
|
-
});
|
|
64
|
-
}
|
|
65
|
-
deserialize(strRecord) {
|
|
66
|
-
let record = JSON.parse(strRecord);
|
|
67
|
-
return new RbtObject(record, this._axios);
|
|
68
|
-
}
|
|
69
70
|
clone() {
|
|
70
71
|
// Create a deep copy of the current object's data
|
|
71
72
|
const clonedData = _.cloneDeep(this._internalData);
|
package/package.json
CHANGED
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
|
-
|
|
44
|
-
|
|
45
|
-
|
|
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,21 +79,6 @@ export default class RbtObject {
|
|
|
67
79
|
};
|
|
68
80
|
}
|
|
69
81
|
|
|
70
|
-
|
|
71
|
-
serialize(){
|
|
72
|
-
|
|
73
|
-
return JSON.stringify({
|
|
74
|
-
...this._internalData,
|
|
75
|
-
dataJson: this._data,
|
|
76
|
-
rpcMeta: this.rpcMeta
|
|
77
|
-
});
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
deserialize(strRecord){
|
|
81
|
-
let record = JSON.parse(strRecord);
|
|
82
|
-
return new RbtObject(record, this._axios);
|
|
83
|
-
}
|
|
84
|
-
|
|
85
82
|
clone() {
|
|
86
83
|
// Create a deep copy of the current object's data
|
|
87
84
|
const clonedData = _.cloneDeep(this._internalData);
|