Skip to content
This repository has been archived by the owner on Oct 29, 2020. It is now read-only.
/ deep-set Public archive

Sets a value of a property in an object tree in Node and the browser.

Notifications You must be signed in to change notification settings

klaemo/deep-set

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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)

  • obj - Object: The original object.
  • path - String: The path to traverse, separated by dots.
  • value - *: The value to set.
  • create - Boolean: Whether to create missing objects along the way default: true.

Tests

npm test

License

MIT

About

Sets a value of a property in an object tree in Node and the browser.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published