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.
- Host: GitHub
- URL: https://github.com/sbimochan/pathify
- Owner: sbimochan
- License: mit
- Created: 2025-04-09T15:34:30.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2025-04-09T16:00:42.000Z (about 1 year ago)
- Last Synced: 2025-10-25T13:58:56.027Z (8 months ago)
- Language: JavaScript
- Size: 7.81 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
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'
}
}
}
```