(WWYD) What Would You Do - #0
I'm working on a little js library with some functions I use a lot and are not present in other libs I currently use.
I recently needed a function that receives an object
and returns an array with it's property paths and values:
flatten({ foo: { bar: 'Salmon' }, name: 'John' });
This will return:
[
{
"path": "foo.bar",
"value": "Salmon"
},
{
"path": "name",
"value": "John"
},
{
"path": "foo",
"value": [
{
"path": "foo.bar",
"value": "Salmon"
}
]
}
]
I've been changing the name of the function quite a bit, and the best I could come up with is flatten
, as it return the object as a 1 dimension array of path-value pairs, although I don't feel it fully expresses what it does.
I'm kinda curious on what you would call it? And why?