string-to-path
v1.0.5
Published
Returns the value from given object at set dynamic path
Downloads
7
Maintainers
Readme
String to Path
Return the value from given object using a dynamic path
Great for when you need a dynamic path
Takes two arguments:
1. obj: the object you want to dynamically set a path within.
2. desiredPathAsString: a string, describing the desired path, e.g:
`data.results[${index}].customer.${detailDesired}`.
Returns the value from given object at set dynamic path.
Installation:
npm i string-to-path
Usage
// Import string-to-path
const value = stringToPath(
someObject,
`data.results[${index}].customer.${detailDesired}`
);