unsafe-set

1.0.0 • Public • Published

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

Package Sidebar

Install

npm i unsafe-set

Weekly Downloads

2

Version

1.0.0

License

ISC

Unpacked Size

1.2 kB

Total Files

3

Last publish

Collaborators

  • ennis