Skip to content
🚧 Get and set dot-notated properties within an object.
Branch: master
Clone or download
Latest commit 06f1900 Apr 15, 2019
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.gitignore Upgraded babel to v7 (#4) May 30, 2018
.travis.yml Actually build the project on Travis Nov 4, 2017
LICENSE Updated year in license Jan 17, 2018
README.md Fixed codeblock in README Apr 9, 2018
index.d.ts Add val parameter to set in Typescript file (#6) Apr 14, 2019
index.js Added typescript definitions Apr 9, 2018
package.json v2.0.0 Apr 15, 2019
test.js Made tests compatible with ES6 Apr 9, 2018

README.md

shvl

Get and set dot-notated properties within an object.

NPM version Build Status

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;
You can’t perform that action at this time.