JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 5137
  • Score
    100M100P100Q129168F
  • License MIT

Safely get deep nested properties using dot notation

Package Exports

  • dot-path-value

Readme

dot-path-value

Safely get deep nested properties using dot notation.

npm version npm downloads npm minified bundle size npm gzip minified bundle size

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