1.0.1 • Published 6 years ago

typed-string-path v1.0.1

Weekly downloads
2
License
MIT
Repository
github
Last release
6 years ago

PathOf

Description

Sometimes we need to create a string representation of an object path:

const obj = {
  x: 2,
  y: {
    w: "abc",
    z: true,
  },
}

const path = "y.z"

This small library allows to create a string path in a typed fashion:

import { PATH, pathOf } from "typed-string-path"

...

const path = pathOf<typeof obj>().y.z[PATH]

We have intellisense while typing the path and if the object fields are renamed the path will also be renamed accordingly.

Installation

To install the stable version:

yarn install typed-string-path