caoge c760052ff9 机车状态修改 | 8 months ago | |
---|---|---|
.. | ||
dist | 8 months ago | |
CHANGELOG.md | 8 months ago | |
LICENSE | 8 months ago | |
README.md | 8 months ago | |
index.d.ts | 8 months ago | |
index.js | 8 months ago | |
package.json | 8 months ago |
Get and set dot-notated properties within an object.
<img src="https://webstronauts.com/badges/sponsored-by-webstronauts.svg" alt="Sponsored by The Webstronauts" width="200" height="65">
npm install --save shvl
The UMD build is also available on unpkg:
<script src="//unpkg.com/shvl/dist/shvl.umd.js"></script>
This exposes the shlv object as a global.
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;
Please see CHANGELOG for more information on what has changed recently.
Thanks goes to these wonderful people (emoji key):
Robin van der Vleuten 💬 💻 📖 💡 🤔 🚇 👀 ⚠️ |
ajenkinski 💻 |
This project follows the all-contributors specification. Contributions of any kind welcome!
The MIT License (MIT). Please see License File for more information.