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

0.1.3 • Public • Published

get-value-key

version issues downloads license

Yet another library to get values from objects using a path.

Installation

This package is distributed via npm:

npm install get-value-key

Motivation

I wrote this code in one of my libraries, and needed it in another library so I'm publishing it as a standalone package.

The reason I wrote this in the first place was that existing libraries didn't seem to be maintained for at least a couple of years.

This library covers most use cases, but please be aware that it is not as complete as other ones (see Know limitations).

Usage

import getValueByKey from "get-value-key";

const obj = {
  nested: {
    num: 4,
  },
};

console.log(getValueByKey(obj, "nested.num")); // 4

Known limitations

This library is not as complete as others such as object-path or get-value.

As such, it handles the basic case where the fields of an object are alphanumeric values that don't contain a ".".

Licence

MIT

Dependents (4)

Package Sidebar

Install

npm i get-value-key

Weekly Downloads

1

Version

0.1.3

License

MIT

Unpacked Size

4.74 kB

Total Files

6

Last publish

Collaborators

  • antoniovdlc