1.0.2 • Published 9 months ago

find-value-of-key v1.0.2

Weekly downloads
-
License
MIT
Repository
github
Last release
9 months ago

findValueOfTheKey

A utility function to recursively search through a deeply nested object and find the value associated with a specific key.

Installation

npm install find-value-of-the-key

Usage

const findValueOfTheKey = require('find-value-of-the-key');

const nestedObject = {
  a: {
    b: {
      c: {
        d: 'target value'
      }
    },
    e: {
      f: 'another value'
    }
  }
};

const targetKey = 'd';
const value = findValueOfTheKey(nestedObject, targetKey);
console.log(value); // Output: 'target value'

Contributions to this utility are welcome! If you find any issues or have suggestions for improvements, feel free to open an issue or submit a pull request on the GitHub repository.