property-value
TypeScript icon, indicating that this package has built-in type declarations

0.0.2 • Public • Published

property-value

npm package Build Status Downloads Issues Code Coverage

Module to get property value with property path

Install

npm install property-value

Usage

import { getPropertyValue } from 'property-value';

interface Person {
  age: number;
  name: {
    first: string;
    middle?: string;
    last: string;
  };
}

const p: Person = {
  age: 15,
  name: {
    first: 'Yuyi',
    last: 'Xue',
  },
};

const firstName = getPropertyValue(p, 'name.first');
//=> 'Yuyi'

API

getPropertyValue<T, P>(obj: T, path: P)

obj

Type: object

The source object

path

Type: string

The path of the property to be received

Dependencies (0)

    Dev Dependencies (0)

      Package Sidebar

      Install

      npm i property-value

      Weekly Downloads

      0

      Version

      0.0.2

      License

      MIT

      Unpacked Size

      4.22 kB

      Total Files

      3

      Last publish

      Collaborators

      • hsuehic2023