function removeSomeShit(arr) {
const table = {};
const result = [];
for(const current of arr) {
const {uid, owner, createdAt} = current;
const uidOvnerKey = `${uid}\0${owner}`;
const ownerUidKey = `${owner}\0${uid}`;
const matched = table[uidOvnerKey];
if (matched) {
delete table[uidOvnerKey];
result.push(matched.createdAt > createdAt ? matched : current);
} else {
table[ownerUidKey] = current;
}
};
return Object.values(table).concat(result);
}