Skip to content

developit/dlv

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

dlv(obj, keypath) NPM Build

Safely get a dot-notated path within a nested object.

Why?

Smallest possible implementation: only 120 bytes.

You could write this yourself, but then you'd have to write tests.

Implementation is ripped directly from preact.

Supports ES Modules, CommonJS and globals.

Installation

npm install --save dlv

Usage

import delve from 'dlv';

let obj = {
	a: {
		b: {
			c: 1
		}
	}
};

delve(obj, 'a.b.c') === 1;

delve(obj, 'a.b') === obj.a.b;

delve(obj, 'a.b.c.d') === undefined;

License

MIT

About

Safe deep property access in 120 bytes. x = dlv(obj, 'a.b.x')

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published

Contributors 8