string-to-path
TypeScript icon, indicating that this package has built-in type declarations

1.0.5 • Public • Published

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}`
);

Have fun! 😀

Package Sidebar

Install

npm i string-to-path

Weekly Downloads

0

Version

1.0.5

License

ISC

Unpacked Size

2.67 kB

Total Files

7

Last publish

Collaborators

  • yonch-ribak