What would you call this function?

Keff - Dec 8 '19 - - Dev Community

(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' });
Enter fullscreen mode Exit fullscreen mode

This will return:

[
    {
        "path": "foo.bar",
        "value": "Salmon"
    },
    {
        "path": "name",
        "value": "John"
    },
    {
        "path": "foo",
        "value": [
            {
                "path": "foo.bar",
                "value": "Salmon"
            }
        ]
    }
]

Enter fullscreen mode Exit fullscreen mode

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?

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Terabox Video Player