obj-keypath
get/set object values using keypaths
About
Using dot notation (or the split character of your choice), obj-keypath simplifies getting and setting nested values in objects and arrays.
Install
npm install --save obj-keypath
Usage
var keypath = var data = nested: obj: arr: cool: 'pizza' var value = keypathconsole // 'pizza' keypath value = keypathconsole // 'awesome'
You can optionally add a last argument to the get
and set
methods to use a character other than .
to split the keys.
Here's an example using '/', which is useful for working with objects as they relate to file & url paths:
var data = nested: obj: arr: cool: 'pizza' var value = keypathkeypath
Contributing
Contributions are welcome! Please read the contributing guidelines first.
Conduct
It is important that this project contributes to a friendly, safe, and welcoming environment for all. Read this project's code of conduct
Contact
- issues – Please open issues in the issues queue
- email – Need in-depth support via paid contract? Send an email to sethvincent@gmail.com