Skip to content

A pure function that allows you to retrieve a member of an object or an array utilizing dot notation

Notifications You must be signed in to change notification settings

mikemclaren/fetch-dot

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

21 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

fetchDot Build Status Coverage Status

A pure function that allows you to retrieve a member of an object or an array utilizing dot notation. Super useful in situations where your code may not know what the schema of an object will be, but some configuration or user might.

Usage

const obj = {
	test: 'Test property.',
	nestedObj: {
		test: 'A nested test property.'
	},
	arr: [
		'An array item'
	]
};

fetchDot('test', obj);
// 'Test property.'

fetchDot('nestedObj.test', obj);
// 'A nested test property.'

fetchDot('arr[0]', obj);
// 'An array item'

// If a property does not exist (no matter how nested it is), the function will
// simply return undefined
fetchDot('does.not.exist', obj);
// undefined

About

A pure function that allows you to retrieve a member of an object or an array utilizing dot notation

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages