An open API service indexing awesome lists of open source software.

https://github.com/sbimochan/pathify

A lightweight utility that recursively walks through a nested JavaScript object and replaces all leaf values with their corresponding dot-notation paths.
https://github.com/sbimochan/pathify

Last synced: 5 months ago
JSON representation

A lightweight utility that recursively walks through a nested JavaScript object and replaces all leaf values with their corresponding dot-notation paths.

Awesome Lists containing this project

README

          

# pathify

> Generate dot-notated key paths from deeply nested JavaScript objects โ€” clean, recursive, and zero dependencies.

---

## โœจ Features

- ๐Ÿ” Recursively walks any nested object
- ๐Ÿ“Œ Replaces all leaf values with their full dot-notation paths
- ๐Ÿงผ Preserves original object structure
- ๐Ÿชถ Lightweight โ€” no dependencies
- โš™๏ธ Optional base path prefix

---

## ๐Ÿ“ฆ Install

```bash
npm install @sbimochan/pathify
```

## Test

```bash
npm run test
```

## Usage

```javascript
const { pathify } = require("@sbimochan/pathify");
const output = pathify(input);
```

```javascript
const input = {
user: {
profile: {
name: "",
age: ""
},
settings: {
theme: ""
}
}
};
```

### Expected output

```javascript
{
user: {
profile: {
name: 'user.profile.name',
age: 'user.profile.age'
},
settings: {
theme: 'user.settings.theme'
}
}
}
```