roboto-js 1.4.27 → 1.4.28

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.
@@ -79,12 +79,14 @@ var RbtObject = exports["default"] = /*#__PURE__*/function () {
79
79
  var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
80
80
  var currentValue = _lodash["default"].get(this._data, path); // Fetch current value at deep path
81
81
 
82
- // Check if merge is required
83
82
  if (options.merge) {
84
- // Merge the value if merge option is true
85
83
  var mergedValue = _lodash["default"].mergeWith({}, currentValue, value, function (objValue, srcValue) {
86
84
  if (_lodash["default"].isArray(objValue)) {
87
- return srcValue; // Customize merging behavior for arrays or other specific types
85
+ return srcValue; // Customize merging behavior for arrays
86
+ }
87
+ // Handle null, 0, and "" explicitly
88
+ if (srcValue === null || srcValue === 0 || srcValue === "") {
89
+ return srcValue;
88
90
  }
89
91
  });
90
92
  if (!_lodash["default"].isEqual(currentValue, mergedValue)) {
@@ -92,7 +94,6 @@ var RbtObject = exports["default"] = /*#__PURE__*/function () {
92
94
  this._addChange(path);
93
95
  }
94
96
  } else {
95
- // Set the value directly if no merge option or merge option is false
96
97
  if (!_lodash["default"].isEqual(currentValue, value)) {
97
98
  _lodash["default"].set(this._data, path, value); // Set the value directly at the deep path
98
99
  this._addChange(path);
@@ -113,10 +114,13 @@ var RbtObject = exports["default"] = /*#__PURE__*/function () {
113
114
  var currentValue = _lodash["default"].get(_this2._data, path);
114
115
  var newValue = newData[path];
115
116
  if (merge && _lodash["default"].isObject(currentValue) && _lodash["default"].isObject(newValue)) {
116
- // Perform a deep merge on the values at the path
117
117
  var mergedValue = _lodash["default"].mergeWith({}, currentValue, newValue, function (objValue, srcValue) {
118
118
  if (_lodash["default"].isArray(objValue)) {
119
- return srcValue; // Customize merging behavior for arrays or other specific types
119
+ return srcValue; // Customize merging behavior for arrays
120
+ }
121
+ // Handle null, 0, and "" explicitly
122
+ if (srcValue === null || srcValue === 0 || srcValue === "") {
123
+ return srcValue;
120
124
  }
121
125
  });
122
126
  if (!_lodash["default"].isEqual(currentValue, mergedValue)) {
@@ -124,11 +128,9 @@ var RbtObject = exports["default"] = /*#__PURE__*/function () {
124
128
  _this2._addChange(path);
125
129
  }
126
130
  } else if (!_lodash["default"].isEqual(currentValue, newValue)) {
127
- // Directly set the new value at the path
128
131
  _lodash["default"].setWith(_this2._data, path, newValue, function (nsValue, key, nsObject, nsPath) {
129
132
  if (key === nsPath.split('.').pop() && !_lodash["default"].has(nsObject, key)) {
130
- // Create any missing parts of the path as plain objects
131
- return nsObject[key] = {};
133
+ return nsObject[key] = {}; // Create any missing parts of the path as plain objects
132
134
  }
133
135
  return nsValue;
134
136
  });
@@ -49,12 +49,14 @@ export default class RbtObject {
49
49
  set(path, value, options = {}) {
50
50
  const currentValue = _.get(this._data, path); // Fetch current value at deep path
51
51
 
52
- // Check if merge is required
53
52
  if (options.merge) {
54
- // Merge the value if merge option is true
55
53
  const mergedValue = _.mergeWith({}, currentValue, value, (objValue, srcValue) => {
56
54
  if (_.isArray(objValue)) {
57
- return srcValue; // Customize merging behavior for arrays or other specific types
55
+ return srcValue; // Customize merging behavior for arrays
56
+ }
57
+ // Handle null, 0, and "" explicitly
58
+ if (srcValue === null || srcValue === 0 || srcValue === "") {
59
+ return srcValue;
58
60
  }
59
61
  });
60
62
  if (!_.isEqual(currentValue, mergedValue)) {
@@ -62,7 +64,6 @@ export default class RbtObject {
62
64
  this._addChange(path);
63
65
  }
64
66
  } else {
65
- // Set the value directly if no merge option or merge option is false
66
67
  if (!_.isEqual(currentValue, value)) {
67
68
  _.set(this._data, path, value); // Set the value directly at the deep path
68
69
  this._addChange(path);
@@ -80,10 +81,13 @@ export default class RbtObject {
80
81
  const currentValue = _.get(this._data, path);
81
82
  const newValue = newData[path];
82
83
  if (merge && _.isObject(currentValue) && _.isObject(newValue)) {
83
- // Perform a deep merge on the values at the path
84
84
  const mergedValue = _.mergeWith({}, currentValue, newValue, (objValue, srcValue) => {
85
85
  if (_.isArray(objValue)) {
86
- return srcValue; // Customize merging behavior for arrays or other specific types
86
+ return srcValue; // Customize merging behavior for arrays
87
+ }
88
+ // Handle null, 0, and "" explicitly
89
+ if (srcValue === null || srcValue === 0 || srcValue === "") {
90
+ return srcValue;
87
91
  }
88
92
  });
89
93
  if (!_.isEqual(currentValue, mergedValue)) {
@@ -91,11 +95,9 @@ export default class RbtObject {
91
95
  this._addChange(path);
92
96
  }
93
97
  } else if (!_.isEqual(currentValue, newValue)) {
94
- // Directly set the new value at the path
95
98
  _.setWith(this._data, path, newValue, (nsValue, key, nsObject, nsPath) => {
96
99
  if (key === nsPath.split('.').pop() && !_.has(nsObject, key)) {
97
- // Create any missing parts of the path as plain objects
98
- return nsObject[key] = {};
100
+ return nsObject[key] = {}; // Create any missing parts of the path as plain objects
99
101
  }
100
102
  return nsValue;
101
103
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "roboto-js",
3
- "version": "1.4.27",
3
+ "version": "1.4.28",
4
4
  "type": "module",
5
5
  "description": "",
6
6
  "main": "dist/cjs/index.cjs",
package/src/rbt_object.js CHANGED
@@ -53,68 +53,71 @@ export default class RbtObject {
53
53
  }
54
54
 
55
55
  set(path, value, options = {}) {
56
- const currentValue = _.get(this._data, path); // Fetch current value at deep path
56
+ const currentValue = _.get(this._data, path); // Fetch current value at deep path
57
57
 
58
- // Check if merge is required
59
- if (options.merge) {
60
- // Merge the value if merge option is true
58
+ if (options.merge) {
61
59
  const mergedValue = _.mergeWith({}, currentValue, value, (objValue, srcValue) => {
62
- if (_.isArray(objValue)) {
63
- return srcValue; // Customize merging behavior for arrays or other specific types
64
- }
60
+ if (_.isArray(objValue)) {
61
+ return srcValue; // Customize merging behavior for arrays
62
+ }
63
+ // Handle null, 0, and "" explicitly
64
+ if (srcValue === null || srcValue === 0 || srcValue === "") {
65
+ return srcValue;
66
+ }
65
67
  });
66
68
  if (!_.isEqual(currentValue, mergedValue)) {
67
- _.set(this._data, path, mergedValue); // Set the merged value at the deep path
68
- this._addChange(path);
69
+ _.set(this._data, path, mergedValue); // Set the merged value at the deep path
70
+ this._addChange(path);
69
71
  }
70
- } else {
71
- // Set the value directly if no merge option or merge option is false
72
+ } else {
72
73
  if (!_.isEqual(currentValue, value)) {
73
- _.set(this._data, path, value); // Set the value directly at the deep path
74
- this._addChange(path);
74
+ _.set(this._data, path, value); // Set the value directly at the deep path
75
+ this._addChange(path);
75
76
  }
76
- }
77
- }
78
-
79
- setData(newData, options = {}) {
80
- if (typeof newData !== 'object' || newData === null) {
81
- throw new Error('setData expects an object');
82
77
  }
78
+ }
83
79
 
84
- const { merge = false } = options;
85
-
86
- Object.keys(newData).forEach(path => {
87
- const currentValue = _.get(this._data, path);
88
- const newValue = newData[path];
89
-
90
- if (merge && _.isObject(currentValue) && _.isObject(newValue)) {
91
- // Perform a deep merge on the values at the path
92
- const mergedValue = _.mergeWith({}, currentValue, newValue, (objValue, srcValue) => {
93
- if (_.isArray(objValue)) {
94
- return srcValue; // Customize merging behavior for arrays or other specific types
95
- }
96
- });
80
+ setData(newData, options = {}) {
81
+ if (typeof newData !== 'object' || newData === null) {
82
+ throw new Error('setData expects an object');
83
+ }
97
84
 
98
- if (!_.isEqual(currentValue, mergedValue)) {
99
- _.set(this._data, path, mergedValue);
100
- this._addChange(path);
101
- }
102
- } else if (!_.isEqual(currentValue, newValue)) {
103
- // Directly set the new value at the path
104
- _.setWith(this._data, path, newValue, (nsValue, key, nsObject, nsPath) => {
105
- if (key === nsPath.split('.').pop() && !_.has(nsObject, key)) {
106
- // Create any missing parts of the path as plain objects
107
- return nsObject[key] = {};
85
+ const { merge = false } = options;
86
+
87
+ Object.keys(newData).forEach(path => {
88
+ const currentValue = _.get(this._data, path);
89
+ const newValue = newData[path];
90
+
91
+ if (merge && _.isObject(currentValue) && _.isObject(newValue)) {
92
+ const mergedValue = _.mergeWith({}, currentValue, newValue, (objValue, srcValue) => {
93
+ if (_.isArray(objValue)) {
94
+ return srcValue; // Customize merging behavior for arrays
95
+ }
96
+ // Handle null, 0, and "" explicitly
97
+ if (srcValue === null || srcValue === 0 || srcValue === "") {
98
+ return srcValue;
99
+ }
100
+ });
101
+
102
+ if (!_.isEqual(currentValue, mergedValue)) {
103
+ _.set(this._data, path, mergedValue);
104
+ this._addChange(path);
105
+ }
106
+ } else if (!_.isEqual(currentValue, newValue)) {
107
+ _.setWith(this._data, path, newValue, (nsValue, key, nsObject, nsPath) => {
108
+ if (key === nsPath.split('.').pop() && !_.has(nsObject, key)) {
109
+ return nsObject[key] = {}; // Create any missing parts of the path as plain objects
110
+ }
111
+ return nsValue;
112
+ });
113
+ this._addChange(path);
108
114
  }
109
- return nsValue;
110
- });
111
- this._addChange(path);
112
- }
113
- });
115
+ });
114
116
  }
115
117
 
116
118
 
117
119
 
120
+
118
121
  // set(path, value, options = {}) {
119
122
  // const currentValue = _.get(this._data, path);
120
123
  //