set-nested-prop
Set nested object property (supports custom seperator, mutation, forcing creation & multi set)
Table of Contents
Install
This project uses node and npm.
$ npm install set-nested-prop$ # OR $ yarn add set-nested-prop
Usage
// By default the original object is not modified and . is used as a seperator const obj1 = foo: bar: baz: 5 const newObj = console // { foo: { bar: { baz: 6 } } }console // { foo: { bar: { baz: 5 } } } // You can opt in for mutatingconst obj2 = foo: 5 console // 6 // A custom seperator can be used const customObj = console // { foo: { bar: { baz: 7 } } } const forceObj = {}const forceObjResult = console // {foo: {bar: 1}}
Contribute
- Fork it and create your feature branch: git checkout -b my-new-feature
- Commit your changes: git commit -am 'Add some feature'
- Push to the branch: git push origin my-new-feature
- Submit a pull request
License
MIT