hughsk / hughsk/flat

Flatten starting at a specific level

Open
#89 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
1.8k
Forks
197
PR merge metrics
No merged PRs in 30d

Description

Hello,

First thanks for such a great library!

I was wondering if there is a config that will allow me to flatten my JSON file starting at a specific depth instead of always flattening from the root to leaf.

Use case:

Input:

```js
flatten(
{
"foo": {
"bar": {
"a": 1,
"b": 2,
"c": 3
}
},
"amaze": {
"muppet": "wow",
"haw": "maw"
}
}
);
```

Output:

```js
{
"foo": {
"bar.a": 1,
"bar.b": 2,
"bar.c": 3,
},
"amaze": {
"muppet": "wow",
"haw": "maw"
}
}
```

Looking at the current options it seems like this would be the opposite of `maxDepth`. Maybe a `minDepth` option.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.