1.0.0 • Published 4 years ago

unsafe-assign v1.0.0

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

unsafe-assign

Assign to an object at an inner property, createing intermediate properties if necessary. Does not support intermediate arrays like lodash.set. Returns the original, modified object.

  • tiny
  • no dependencies
import assign from 'unsafe-assign';

let obj = {
  a: 'will be clobbered'
}

assign(obj, 'a.aa', {b: 'c'});
assign(obj, 'a.aa', {c: 'd'});

//{a: {aa: {b: 'c', c: 'd'}}}