For example, turn this:
const enums = { ip: 'ip', er: 'er' };
const obj = {
somethingNotNeeded: {...},
er: [
{ a: 1},
{ b: 2}
],
somethingElseNotNeeded: {...},
ip: [
{ a: 1},
{ b: 2}
]
}
Into this:
[
{ a: 1},
{ b: 2},
{ a: 1},
{ b: 2}
]
I'm already doing this in a roundabout way by declaring an enum object of the types i want (er, ip) then doing a forEach (lodash) loop on obj checking if the keys aren't in the enum and delete them off the original obj. Then having just the objects I want, I do two nested forEach loops concatenating the results to a new object using object rest spread...
I'm almost entirely sure there's a better way of doing this but I didn't think of it today.