Given the following Map:
const myMap = new Map([
[“a”, [{
files: [{
name: “f1a”
}, {
name: “f2a”
}]
}]],
[“b”, [{
files: [{
name: “f1b”
}, {
name: “f2b”
}]
}]]
]);
I need to have the following result:
[{
"name": "f1a"
}, {
"name": "f2a"
}, {
"name": "f1b"
}, {
"name": "f2b"
}]
I achieved that using:
[...x.values()].flat().map(x => x.files).flat()
How can the above be optimized, can even use lodash I don't mind.
I tried to use lodash: flattenMapDeep
but didn't work