Open Vitaminaq opened 2 years ago
function transform(A, B) {
const map = new Map();
B.forEach((i) => {
if (i.key === 'id') {
const it = {...i};
delete it.key;
delete it.val;
map.set(i.val, it);
}
});
return A.map(n => {
if (map.has(n.id)) return Object.assign(n, map.get(n.id));
return n;
});
}