unsafe-set
v1.0.0
Published
set value at property, create intermediate properties if necessary, clobbering anything in it's way
Downloads
1
Maintainers
Readme
unsafe-set
Unsafely set a value at a property, creating intermediate properties if necessary. If one doesn't exist, or exists but isn't an object, it will become an object. Does not support intermediate arrays like lodash.set. Returns the original, modified object.
- tiny
- no dependencies
import set from 'unsafe-set';
let obj = {
a: 'foo'
}
set(obj, 'a.aa.aaa', 'bar');
//{a: {aa: {aaa: 'bar'}}}