Home

Awesome

deep-set

testling badge Build Status

Sets a value of a property in an object tree. Missing objects will (optionally) be created.

Installation

npm install deep-set

In the browser you can use deepSet with Browserify, RequireJS or as a window global.

Usage

var deepSet = require('deep-set')
var obj = { one: { two: { three: 'sad' } } }

deepSet(obj, 'one.two.three', 'yay')
// { one: { two: { three: 'yay' } } }

Arguments

deepSet(obj, path, value, create)

Tests

npm test

License

MIT