1.0.0 • Published 4 years ago

unsafe-set v1.0.0

Weekly downloads
-
License
ISC
Repository
-
Last release
4 years ago

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'}}}