# x-deep-object-traversal

> **xDeepObjectTraversal** is a recursive function that traverses a nested object and calls a callback function for each key-value pair it encounters. It is a depth-first traversal, meaning it explores as deeply into the nested objects as possible before mo

Latest version **11.0.1** (published 2023-09-02) · MIT license · 0 weekly downloads

## Install

```sh
npm install x-deep-object-traversal
pnpm add x-deep-object-traversal
yarn add x-deep-object-traversal
bun add x-deep-object-traversal
```

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 11.0.1 |
| Published | 2023-09-02 |
| First published | 2023-09-01 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 19.7 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | nhutdm |
| Maintainers | nhutdm198 |
| Keywords | x-deep-object-traversal, x deep object traversal, deep object traversal, loop through deep object, deep object iteration, object traversal, deep object |

## Links

- npm: https://www.npmjs.com/package/x-deep-object-traversal
- npm.io page: https://npm.io/package/x-deep-object-traversal

## Recent versions

- 11.0.1 (latest) — 2023-09-02
- 10.0.1 — 2023-09-01

## README

**xDeepObjectTraversal** is a recursive function that traverses a nested object and calls a callback function for each key-value pair it encounters. It is a depth-first traversal, meaning it explores as deeply into the nested objects as possible before moving on to the next sibling key at the current level.

## Installation

To use xDeepObjectTraversal, you'll need to include the provided TypeScript file in your project.

1. Download the `xDeepObjectTraversal.ts` file from this repository.
2. Add the file to your project directory.

## Usage

1. Import the `xDeepObjectTraversal` class into your TypeScript code:

   ```typescript
   import { xDeepObjectTraversal } from 'x-deep-object-traversal'
   const nestedObject = {
      a: 1,
      b: {
        c: 2,
        d: {
          e: 3,
          f: 4,
        },
      },
    };
   function logKeyAndValue(key, value) {
     console.log(`Key: ${key}, Value: ${value}`);
   }

   xDeepObjectTraversal(deepArray, logKeyAndValue);
   // Key: a, Value: 1
   // Key: b, Value: { c: 2, d: { e: 3, f: 4 } }
   // Key: c, Value: 2
   // Key: d, Value: { e: 3, f: 4 }
   // Key: e, Value: 3
   // Key: f, Value: 4


2. Import the `xDeepObjectTraversal` class into your Javascript code:

   ```javascript
   const { xDeepObjectTraversal } = require("x-deep-object-traversal")
    const nestedObject = {
      a: 1,
      b: {
        c: 2,
        d: {
          e: 3,
          f: 4,
        },
      },
    };
   function logKeyAndValue(key, value) {
     console.log(`Key: ${key}, Value: ${value}`);
   }

   xDeepObjectTraversal(deepArray, logKeyAndValue);
   // Key: a, Value: 1
   // Key: b, Value: { c: 2, d: { e: 3, f: 4 } }
   // Key: c, Value: 2
   // Key: d, Value: { e: 3, f: 4 }
   // Key: e, Value: 3
   // Key: f, Value: 4

## Support Me

If you find this project helpful or want to show your appreciation, you can support me by [buying me a coffee](https://www.buymeacoffee.com/nhutdm). Your support is greatly appreciated!

---
_Source: https://npm.io/package/x-deep-object-traversal · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
