Implement set(obj, path, value)
The write-side counterpart to get. Write set(obj, path, value) that writes value at the given dot/bracket path, creating any missing intermediate objects or arrays along the way, an array when the next segment is numeric, an object otherwise. Mutates obj in place and returns it.
set({}, "a.b.c", 42); // { a: { b: { c: 42 } } }
set({}, "a[0].b", "x"); // { a: [{ b: "x" }] }