Unflatten method doesn't work with "toString" key
- Dominant language
- JavaScript
- Stars
- 1.8k
- Forks
- 197
- PR merge metrics
- No merged PRs in 30d
Description
### Problem
The `unflatten` method doesn't work with a key named `toString`.
For example, starting with this object:
```
{
"p5": {
"y": "The y component of the vector",
"toString": {
"returns": "String: "
}
}
}
```
Then flatten it:
```
{
'p5/y': 'The y component of the vector',
'p5/toString/returns': 'String: '
}
```
And then unflatten it:
```
{
"p5": {
"y": "The y component of the vector"
}
}
```
The `toString` key disappears.
### Workaround
I ended up adding a prefix to all the keys while flattening the object (with the `transformKey` option), and then removing it after unflattening it again. To remove the prefix I used the `map-obj` library to map all the key and values from the original object to a new one, where the keys were substrings of the original ones.
Contributor guide
No contributing guide indexed for this repository
Research direction
Start at the unflatten entry point and reproduce the supplied nested object containing a "toString" key, comparing the flattened and unflattened results. The work is done when unflatten preserves that key and its nested "returns" value without requiring the transformKey workaround.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100