https://github.com/robinvdvleuten/shvl
🚧 Get and set dot-notated properties within an object.
https://github.com/robinvdvleuten/shvl
dot-notation getter javascript object setter
Last synced: about 1 year ago
JSON representation
🚧 Get and set dot-notated properties within an object.
- Host: GitHub
- URL: https://github.com/robinvdvleuten/shvl
- Owner: robinvdvleuten
- License: mit
- Created: 2017-11-02T08:44:12.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2022-08-29T14:35:52.000Z (almost 4 years ago)
- Last Synced: 2024-04-24T08:31:08.411Z (about 2 years ago)
- Topics: dot-notation, getter, javascript, object, setter
- Language: JavaScript
- Homepage: https://npm.im/shvl
- Size: 406 KB
- Stars: 73
- Watchers: 4
- Forks: 13
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# shvl
Get and set dot-notated properties within an object.

[](https://github.com/robinvdvleuten/shvl/actions?query=workflow%3Atest)
[](https://www.npmjs.com/package/shvl)
[](https://www.npmjs.com/package/shvl)
[](https://github.com/robinvdvleuten/shvl/blob/master/LICENSE)
[](http://makeapullrequest.com)
## Installation
```
npm install --save shvl
```
The [UMD](https://github.com/umdjs/umd) build is also available on [unpkg](https://unpkg.com/shvl/dist/shvl.umd.js):
```
```
This exposes the shlv object as a global.
## Usage
```js
import * as shvl from 'shvl';
let obj = {
a: {
b: {
c: 1
d: undefined
e: null
}
}
};
// Use dot notation for keys
shvl.set(obj, 'a.b.c', 2);
shvl.get(obj, 'a.b.c') === 2;
// Or use an array as key
shvl.get(obj, ['a', 'b', 'c']) === 1;
// Returns undefined if the path does not exist and no default is specified
shvl.get(obj, 'a.b.c.f') === undefined;
```
## Changelog
Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.
## Contributors ✨
Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/docs/en/emoji-key)):

Robin van der Vleuten
💬 💻 📖 💡 🤔 🚇 👀 ⚠️

ajenkinski
💻

Matheus Vrech
💻
This project follows the [all-contributors](https://github.com/all-contributors/all-contributors) specification. Contributions of any kind welcome!
## License
The MIT License (MIT). Please see [License File](LICENSE) for more information.