@bian-womp/spark-graph 0.3.63 → 0.3.65

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/lib/cjs/index.cjs CHANGED
@@ -1111,9 +1111,11 @@ function setValueAtPathWithCreation(root, pathSegments, value) {
1111
1111
  if (value === null) {
1112
1112
  const result = getValueAtPath(root, pathSegments);
1113
1113
  if (result && result.parent !== null && !Array.isArray(result.parent)) {
1114
+ const hadValue = result.key in result.parent;
1114
1115
  delete result.parent[result.key];
1116
+ return hadValue;
1115
1117
  }
1116
- return;
1118
+ return false;
1117
1119
  }
1118
1120
  if (!root || typeof root !== "object" || Array.isArray(root)) {
1119
1121
  throw new Error("Root must be an object");
@@ -1145,7 +1147,10 @@ function setValueAtPathWithCreation(root, pathSegments, value) {
1145
1147
  if (!current || typeof current !== "object" || Array.isArray(current)) {
1146
1148
  throw new Error(`Cannot set value: parent at final segment is not an object`);
1147
1149
  }
1150
+ const hadValue = lastSegment in current;
1151
+ const oldValue = current[lastSegment];
1148
1152
  current[lastSegment] = value;
1153
+ return !hadValue || JSON.stringify(oldValue) !== JSON.stringify(value);
1149
1154
  }
1150
1155
  else {
1151
1156
  throw new Error("Array indices not supported in extData paths");