MCPcopy Create free account
hub / github.com/JamieMason/syncpack / set_nested_prop

Function set_nested_prop

src/disk.rs:645–653  ·  view source on GitHub ↗

Set a key on a parent object. Uses direct Map access so keys may contain `/` (eg. scoped npm packages like `@scope/name`). Marks dirty only when the value actually changed.

(file: &mut File<JsonValue>, parent_pointer: &str, key: &str, next_value: JsonValue)

Source from the content-addressed store, hash-verified

643/// `/` (eg. scoped npm packages like `@scope/name`). Marks dirty only when
644/// the value actually changed.
645pub fn set_nested_prop(file: &mut File<JsonValue>, parent_pointer: &str, key: &str, next_value: JsonValue) {
646 if let Some(JsonValue::Object(obj)) = file.contents.pointer_mut(parent_pointer) {
647 let is_changed = obj.get(key).is_none_or(|value| json_values_differ(value, &next_value));
648 if is_changed {
649 obj.insert(key.to_string(), next_value);
650 file.dirty = true;
651 }
652 }
653}
654
655/// Remove a key from a parent object. Marks dirty only when the key existed.
656pub fn remove_prop(file: &mut File<JsonValue>, parent_pointer: &str, key: &str) {

Calls 1

json_values_differFunction · 0.85

Used in the wild real call sites across dependent graphs

searching dependent graphs…