xiezongxing 42747a5135 Signed-off-by: xiezongxing <xx123456> 2 年之前
..
dist 42747a5135 Signed-off-by: xiezongxing <xx123456> 2 年之前
LICENSE 42747a5135 Signed-off-by: xiezongxing <xx123456> 2 年之前
README.md 42747a5135 Signed-off-by: xiezongxing <xx123456> 2 年之前
index.d.ts 42747a5135 Signed-off-by: xiezongxing <xx123456> 2 年之前
index.js 42747a5135 Signed-off-by: xiezongxing <xx123456> 2 年之前
package.json 42747a5135 Signed-off-by: xiezongxing <xx123456> 2 年之前

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;