Package Exports
- dot-path-value
Readme
dot-path-value
Safely get deep nested properties using dot notation.
Features
- TypeScript first 🤙
- Support arrays
- Tiny (198b gzipped)
- No dependencies
Installation
# using npm
npm install dot-path-value
# using pnpm
pnpm install dot-path-value
# using yarn
yarn add dot-path-value
Usage
import { getByPath } from "dot-path-value";
const obj = {
a: {
b: {
c: "hello",
},
},
};
getByPath(obj, "a.b.c"); // outputs 'hello'
Types
dot-path-value
exports a few types to ensure the type safety:
Type | Description |
---|---|
Path<T> |
converts nested structure T into a string representation of the paths to its properties |
PathValue<T, TPath> |
returns the type of the value at the specified path |