shv

shvl

🚧 Get and set dot-notated properties within an object.

Showing:

Popularity

Downloads/wk

155K

GitHub Stars

64

Maintenance

Last Commit

4mos ago

Contributors

2

Package

Dependencies

0

Size (min+gzip)

0.3KB

License

MIT

Type Definitions

Built-In

Tree-Shakeable

Yes?

Categories

Readme

shvl

Get and set dot-notated properties within an object.


Build Status NPM version NPM downloads MIT license

PRs Welcome

Sponsored by The Webstronauts

Installation

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.

Usage

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 for more information on what has changed recently.

Contributors ✨

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!

License

The MIT License (MIT). Please see License File for more information.

Rate & Review

Great Documentation0
Easy to Use0
Performant0
Highly Customizable0
Bleeding Edge0
Responsive Maintainers0
Poor Documentation0
Hard to Use0
Slow0
Buggy0
Abandoned0
Unwelcoming Community0
100