Closed o0101 closed 5 years ago
Hey, I'm not sure if I'm understanding correctly.
Are you looking to get the deeply-nested values via a keypath? If so, then dlv
covers that for you.
Or, are you wanting to convert an object into a flat object with values?
let obj = {
a: 1,
b: {
c: 3,
d: {
e: 5
}
}
}
//=>
{
a: 1,
'b.c': 3,
'b.d.e': 5
}
If that's the case, then you can use flat-obj
and change the glue
to '.'
(or whatever you want).
Ah, @lukeed you already did this! 😂 Amazing you come up with some many useful, specific utilities. True skill you have. Very cool.
BTW I meant your second case. So https://github.com/lukeed/flat-obj covers that for objects. Does it also work if arrays are in the structure?
Haha, thanks! There are lots of them I learned (over time) but I just write things that I need when I needed them, especially when I was getting started. I think that module was one of my first modules ever, too
It will handle array keys but the initial item has to be an object
Turn an object into the minimal set of key paths and values.