| 1 |
// Accepts an object and a list of selected keys |
| 2 |
// and returns a new object with only the selected keys. |
| 3 |
export const objectFromKeys = (sourceObject, selectedKeys) => |
| 4 |
Object.entries(sourceObject) |
| 5 |
.filter(([key]) => selectedKeys.includes(key)) |
| 6 |
.reduce((acc, [key, value]) => { |
| 7 |
acc[key] = value; |
| 8 |
return acc; |
| 9 |
}, {}); |
| 10 |
|