mpath icon indicating copy to clipboard operation
mpath copied to clipboard

set() does not create a nested structure

Open olastor opened this issue 3 years ago • 4 comments

Perhaps this is expected behaviour, but I do not understand why this does not work:

const obj = {};
mpath.set('a.b', 3, obj);
console.log(obj); // => {}

It returns an empty object {}, while I was expecting it to return { a: { b: 3 } }. Using .get() it works the other way around:

const obj = { a: { b: 3 } };
console.log(mpath.get('a.b', obj)); // => 3

olastor avatar May 15 '21 14:05 olastor